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 mvninstead.
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 deployThe 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 SUCCESSSkipping artifact deployment refers to Maven's own deployer and is expected. The plugin performs the upload immediately afterward.
What You Should See Next
- Confirm the artifact under
libs-release-localorlibs-snapshot-local, depending on whether the Maven version ends in-SNAPSHOT. - 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.
- If JFrog CLI is configured, verify Artifactory connectivity:
jf rt pingHow 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.
| Block | Purpose |
|---|---|
publisher | Artifactory URL, credentials, release and snapshot repository keys, artifact and build-info controls |
resolver | Artifactory repositories used to resolve release and snapshot dependencies |
buildInfo | Build name, number, URL, JFrog Project key, principal, and retention settings |
artifactory | Environment-variable collection and connection timeout |
deployProperties | Properties attached to each deployed artifact |
proxy | HTTP or HTTPS proxy. Otherwise, the plugin uses the active Maven settings.xml proxy |
Publisher Options
The publisher block supports the following parameters.
| Parameter | Default | Purpose |
|---|---|---|
repoKey | — | Release deployment repository |
snapshotRepoKey | — | Snapshot deployment repository |
publishArtifacts | true | Deploy artifacts |
publishBuildInfo | true | Publish build information |
filterExcludedArtifactsFromBuild | false | Remove excluded artifacts from build-info |
recordAllDependencies | false | Include implicit and build-time dependencies |
minChecksumDeploySizeKb | 10 | Minimum 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.
| Problem | Resolution |
|---|---|
Skipping artifact deployment looks like a failure | Expected. Maven's own deployer is skipped so the plugin can upload. Check for the Deploying artifact lines that follow. |
| 401 or 403 during deploy | Check the publisher credentials and the deploy and build-info permissions. |
| Snapshot goes to the release repository | Ensure the project version ends in -SNAPSHOT and set snapshotRepoKey. |
| Nothing is deployed | Run mvn deploy, not only mvn package. Confirm publishArtifacts is not false. |
| Build information is missing | Confirm publishBuildInfo is not false and the user can publish build-info. |
| The build's Environment tab is empty | Expected unless includeEnvVars is true. Environment collection is off by default. |
| Dependency resolution still uses Maven Central | Add and verify the resolver block. Deployment and resolution are separate. |
| Sensitive values appear in build-info | Tighten envVarsExcludePatterns. Never store secrets in pom.xml. |
| Proxy connection fails | Configure proxy or verify the active proxy in Maven settings.xml. |
Related Topics
Updated about 1 month ago
