Maven Artifactory Plugin

Deploy Maven artifacts and publish build information to JFrog Artifactory.

The Maven Artifactory Plugin is for Maven developers who want publishing configured in the project build. It deploys release and snapshot artifacts and publishes build information to JFrog Artifactory.

📘

Note

Use this plugin when the Maven build owns its Artifactory publishing configuration. If your CI is already centered on JFrog CLI, use jf mvn instead.

Prerequisites

  • Maven 3.8.1 or later.
  • Java 8 or later.
  • A JFrog Artifactory instance.
  • Maven local repositories for releases and snapshots, with deploy permission.
  • A username and access token or password stored outside source control.
  • Use the same Maven build name and number for deploy and build-info publish.

Before You Begin

Confirm the Maven local repository type, deploy plus publish-build-info permission, and a single build identity. For the model these steps assume, see . To choose between the plugin and jf mvn, see .

Quick Start

To deploy Maven artifacts and publish build information to Artifactory:

Add the plugin to the <build> section of pom.xml. This example uses version 3.7.1. Confirm the current release before pinning it.

<plugin>
  <groupId>org.jfrog.buildinfo</groupId>
  <artifactId>artifactory-maven-plugin</artifactId>
  <version>3.7.1</version>
  <executions>
    <execution>
      <id>publish-to-artifactory</id>
      <goals><goal>publish</goal></goals>
      <configuration>
        <publisher>
          <contextUrl>${artifactory.contextUrl}</contextUrl>
          <username>${artifactory.username}</username>
          <password>${artifactory.token}</password>
          <repoKey>libs-release-local</repoKey>
          <snapshotRepoKey>libs-snapshot-local</snapshotRepoKey>
        </publisher>
      </configuration>
    </execution>
  </executions>
</plugin>

Provide artifactory.contextUrl, artifactory.username, and artifactory.token through Maven settings, CI secrets, or protected environment-specific properties. Do not commit credentials.

Run:

mvn deploy

The plugin's publish goal runs in Maven's validate phase and replaces Maven's normal deployment with an Artifactory-aware deployer. A successful run ends like this:

[INFO] Skipping artifact deployment
[INFO] Deploying artifact: .../org/example/app/1.0.0/app-1.0.0.jar
[INFO] Deploying artifact: .../org/example/app/1.0.0/app-1.0.0.pom
[INFO] Artifactory Build info recorder: Deploying build info ...
[INFO] Build-info successfully deployed.
[INFO] BUILD SUCCESS

Skipping artifact deployment refers to Maven's own deployer and is expected. The plugin performs the upload immediately afterward.

What You Should See Next

  1. Confirm the artifact under libs-release-local or libs-snapshot-local, depending on whether the Maven version ends in -SNAPSHOT.
  2. In the JFrog Platform UI, go to Artifactory > Builds and open your build name, then the build number. The Published Modules tab lists each module with its artifact and dependency counts.
  3. If JFrog CLI is configured, verify Artifactory connectivity:
jf rt ping

How the Lifecycle Integration Works

The publish goal is bound to validate, the earliest lifecycle phase. During validation, the plugin resolves {{...}} expressions, configures proxy and resolution behavior, and replaces the normal deployer. Artifacts and build information are sent only after all modules complete.

Do not move the goal to a later phase unless you have a tested reason.

Configuration Reference

The plugin configuration supports the following blocks.

BlockPurpose
publisherArtifactory URL, credentials, release and snapshot repository keys, artifact and build-info controls
resolverArtifactory repositories used to resolve release and snapshot dependencies
buildInfoBuild name, number, URL, JFrog Project key, principal, and retention settings
artifactoryEnvironment-variable collection and connection timeout
deployPropertiesProperties attached to each deployed artifact
proxyHTTP or HTTPS proxy. Otherwise, the plugin uses the active Maven settings.xml proxy

Publisher Options

The publisher block supports the following parameters.

ParameterDefaultPurpose
repoKey—Release deployment repository
snapshotRepoKey—Snapshot deployment repository
publishArtifactstrueDeploy artifacts
publishBuildInfotruePublish build information
filterExcludedArtifactsFromBuildfalseRemove excluded artifacts from build-info
recordAllDependenciesfalseInclude implicit and build-time dependencies
minChecksumDeploySizeKb10Minimum size for checksum deployment. 0 disables the optimization

Build Information

Use buildInfo to override defaults:

<buildInfo>
  <buildName>orders-service</buildName>
  <buildNumber>${env.BUILD_NUMBER}</buildNumber>
  <buildUrl>${env.BUILD_URL}</buildUrl>
  <project>${env.JF_PROJECT}</project>
</buildInfo>

If not set, the build name defaults to the Maven artifactId and the number defaults to a build timestamp. For more information about the published build-info, see .

Safe Environment Collection

Environment collection is off unless you enable it. Without an <artifactory> block, build-info records no environment or system variables. Enable it explicitly and keep the secret exclusions, or make them stricter:

<artifactory>
  <includeEnvVars>true</includeEnvVars>
  <envVarsExcludePatterns>*password*,*secret*,*key*,*token*,*passphrase*</envVarsExcludePatterns>
</artifactory>

Collected variables appear on the build's Environment tab, under Environment Variables and System Variables. Keys matching the exclude patterns are dropped before publication.

Example

See the multi-module Maven example.

Troubleshooting

The following table lists common problems and their resolutions.

ProblemResolution
Skipping artifact deployment looks like a failureExpected. Maven's own deployer is skipped so the plugin can upload. Check for the Deploying artifact lines that follow.
401 or 403 during deployCheck the publisher credentials and the deploy and build-info permissions.
Snapshot goes to the release repositoryEnsure the project version ends in -SNAPSHOT and set snapshotRepoKey.
Nothing is deployedRun mvn deploy, not only mvn package. Confirm publishArtifacts is not false.
Build information is missingConfirm publishBuildInfo is not false and the user can publish build-info.
The build's Environment tab is emptyExpected unless includeEnvVars is true. Environment collection is off by default.
Dependency resolution still uses Maven CentralAdd and verify the resolver block. Deployment and resolution are separate.
Sensitive values appear in build-infoTighten envVarsExcludePatterns. Never store secrets in pom.xml.
Proxy connection failsConfigure proxy or verify the active proxy in Maven settings.xml.

Related Topics


Did this page help you?