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





You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Overview

To perform Maven builds in Pipelines for Artifactory, your Maven projects will need additional configuration.

Pipelines requires the Maven Artifactory Plugin to fully integrate Artifactory with Maven builds. The plugin is required for correct operation of the MvnBuild native step, or when invoking Maven from a Bash generic step.

The procedures shown here will enable the plugin to access Artifactory through the credentials stored in the Artifactory Integration that is used by your pipeline.

Page Contents


Usage

First, configure the Project Object Model {pom.xml) configuration file of your Maven project to use the Maven Artifactory Plugin.

The Maven Artifactory Plugin will need to know your Artifactory credentials to be able to publish your Maven builds to repositories. You can provide this information in the Maven project's pom.xml configuration file, in the publisher block along with the names of the repositories where artifacts are to be published.

<publisher>
  <contextUrl> .. </contextUrl>
  <username> .. </username>
  <password> .. </password>
  <repoKey> .. </repoKey>
  <snapshotRepoKey> .. </snapshotRepoKey>
</publisher>

To keep this credential information secure, your pom.xml should reference these values as system properties that you have defined in your Maven project's settings.xml configuration file.

For even greater security, you should declare those properties in settings.xml using the environment variables provided by the Artifactory Integration to the step's execution environment. This also makes your Maven project adaptable to Pipelines – you can change which Artifactory instance is used in your pipeline without having to change your Maven project.

For example, this settings.xml file references the credentials and URL stored in the MyArtifactory integration:

settings.xml
<settings>
    <profiles>
        <profile>
            <id>artifactory-plugin-properties</id>
            <properties>
                <username>${env.int_MyArtifactory_user}</username>
                <password>${env.int_MyArtifactory_apikey}</password>
                <artifactoryUrl>${env.int_MyArtifactory_url}</artifactoryUrl>
            </properties>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>artifactory-plugin-properties</activeProfile>
    </activeProfiles>
</settings>

Note that the MyArtifactory integration must have been specified in the step's integrations tag (required for the MvnBuild native step) for these environment variables to be available to the step's execution environment.

Once defined in settings.xml, these properties can then be referenced in the pom.xml configuration file:

pom.xml
<publisher>
  <contextUrl>${artifactoryUrl}</contextUrl>
  <username>${username}</username>
  <password>${password}</password>
  <repoKey>libs-release-local</repoKey>
  <snapshotRepoKey>libs-snapshot-local</snapshotRepoKey>
</publisher>
  • No labels
Copyright © 2022 JFrog Ltd.