Cloud customer?
Start for Free>
Upgrade in MyJFrog >
What's New in Cloud >







Overview

The Maven Artifactory Plugin, Artifactory is fully integrated with Maven builds and allows you to do the following:
  1. Attach properties to published artifacts in Artifactory metadata.
  2. Capture aBuild Infoobject which can be passed to theArtifactory REST APIto provide a fully traceable build context.
  3. Automatically publish all build artifacts at the end of the build.

Source Code Available!

The Maven Artifactory Plugin is anopen-source project on GitHubwhich you can freely browse and fork.

Page Contents


Usage

The Maven Artifactory Plugin coordinates areorg.jfrog.buildinfo:artifactory-maven-plugin:x.x.x.It can be viewed onoss.jfrog.org.

A typical build plugin configuration would be as follows:

  ...  org.jfrog.buildinfo artifactory-maven-plugin 3.4.0 false   build-info  publish    awesome qa   https://oss.jfrog.org deployer {DESede}... libs-release-local libs-snapshot-local       

The plugin's invocation phase isvalidateby default and we recommend you don't change it so the plugin is called as early as possible in the lifecycle of your Maven build.


配置

The example above configures the Artifactorypublisher, to deploy build artifacts either to thereleasesor thesnapshotsrepository of thepublic OSS instance of Artifactorywhenmvn deployis executed.

However, the Maven Artifactory Plugin provides many other configurations which you can see by runningmvn -X validateand are displayed below:

 ..    ..   ..  true/false N    ..   ..   ..   ..   ..  true/false true/false  ..   ..  true/false  true/false  10    ..   ..   ..   ..    ..   ..  N N  ..   ..  

Specifiespropertiesyou can attach to published artifacts. For example:

 ${project.groupId} ${project.artifactId} ${project.version} 
指定环境变量是否及其作者hed as part ofBuildInfometadata and which include or exclude patterns are applied when variables are collected

Defines an Artifactory repository where build artifacts should be published using a combination of aand/.

Build artifacts are deployed if thedeploygoal is executed and only after all modules are built

UpdatesBuildInfometadata published together with build artifacts. You can configure whether or notBuildInfometadata is published using theconfiguration.

Reading Environment Variables and System Properties

每一个构建服务器提供了它自己的set of environment variables. You can utilize these variables when configuring the plugin as shown in the following example:

1
2
3
4
5
6
7
8

<publisher>
<contextUrl>{{ARTIFACTORY_CONTEXT_URL|"https://oss.jfrog.org"}}contextUrl>
...
publisher>
<buildInfo>
<buildNumber>{{DRONE_BUILD_NUMBER|TRAVIS_BUILD_NUMBER|CI_BUILD_NUMBER|BUILD_NUMBER|"333"}}buildNumber>
<buildUrl>{{DRONE_BUILD_URL|CI_BUILD_URL|BUILD_URL}}buildUrl>
buildInfo>

Any plugin configuration value can contain several{{ .. }}expressions. Each expression can contain a single or multiple environment variables or system properties to be used.

The expression syntax allows you to provide enough variables to accommodate any build server requirements according to the following rules:

  • Each expression can contain several variables, separated by a ' | ' character to be used with a configuration value
  • The last value in a list is the default that will be used if none of the previous variables is available as an environment variable or a system property

For example, for the expression{{V1|V2|"defaultValue"}}the plugin will attempt to locate environment variableV1, then system propertyV1, then environment variable or system propertyV2, and if none of these is available, "defaultValue" will be used.

If the last value is not a string (as denoted by the quotation marks) and the variable cannot be resolved,nullwill be used (for example, for expression{{V1|V2}}where neitherV1norV2can be resolved).

Examples

The following project provides a working example of using the plugin:

Maven Artifactory Plugin


Release Notes

3.5.1 (27 Nov 2022)
  • Pom doesn't get deployed using Maven Install plugin 3+
3.5.0 (24 Nov 2022)
  • Support maven.deploy.skip property on a module
  • Update dependencies
3.4.0 (14 Feb 2021)
  • Add support for artifactory projects.
  • Verify artifact type length limit (64).
  • Update build-info to 2.35.0.
3.3.0 (12 Sep 2021)
  1. Populate build-info with VCS information.
3.2.3 (6 Jun 2021)
  1. Update build-info-extractor to 2.26.4.
3.2.1 (16 February 2021)
  1. Plugin is uploaded to Maven Central.
  2. Bugfix - Replaced variables are overridden after a project started.
3.2.0 (18 January 2021)
  1. Allow plugin to be inherited.
  2. Allow configuring the minimal file size for the checksum deploy algorithm.
3.1.0 (14 January 2021)
  1. Reintroduce the expression syntax algorithm of environment and system variables.
3.0.0 (30 September 2020)
  1. Migrate code base fromhttps://github.com/jfrog/build-infotohttps://github.com/jfrog/artifactory-maven-plugin.
  2. Parallel artifacts deployment using 3 threads.
  3. Build-info - Populate the Build Agent with the plugin name and version.
  4. Breaking changes:andconfigurations had been removed.
  5. Breaking changes: The expression syntax algorithm of environment and system variables had been removed.
  • No labels
Copyright © 2023 JFrog Ltd.