Have a question? Want to report an issue? Contact JFrog support

Skip to end of metadata
Go to start of metadata

Overview

The Jenkins Artifactory Plugin supports Gradle build jobs, allowing your build jobs deploy artifacts and resolve dependencies to and from Artifactory, and then have them linked to the build job that created them.

As described below, using the  Jenkins Gradle Plugin, you can create a freestyle job with the Artifactory Gradle integration. 

To help you get started, you can use gradle-example-ci-server as a sample project you can build from your Jenkins Gradle job.


Page Contents

Integration Benefits


Configuring Gradle Builds

Deploy Artifacts to Artifactory

Once you have at least one Artifactory server configured, you can add the deployment details in your Gradle build.

Artifactory deployment server
Artifactory server as defined in the Artifactory plugin configuration. The selected server will be used for artifacts resolution and build info deployment.
Publishing repository

Repository to deploy artifacts to.

Using the text mode will enable you to also use placeholders for environment variable which will be replaced with your environment value at build time.

Custom staging configuration
Select a named staging configuration defined by an Artifactory User Plugin or select "None" to use the default staging settings.
Override default credentials
Override default credentials.

Resolve Artifacts from Artifactory

Artifactory resolve server
Artifactory server as defined in the Artifactory plugin configuration. The selected server will be used for artifacts resolution and build info deployment.
Resolution repository
Repository used to download artifacts from.
Override default credentials
Override default credentials.

Job Configuration

Project uses the Artifactory Gradle Plugin

If this checkbox is not set, Jenkins assumes that the com.jfrog.artifactory plugin is not applied in the gradle script. It will then try to apply it, by adding an init script when triggering the gradle build.

Capture and publish build info

Check if you wish to publish build information to Artifactory.

Override build name

Check if you wish to override Artifactory default build name.

Publish artifacts to Artifactory

Check if you wish to publish produced build artifacts to Artifactory.

Publish Maven descriptors

Check if you wish to publish Gradle-generated POM files to Artifactory. Note: Maven descriptors are always deployed according to the Maven layout convention.

Publish Ivy descriptors

Check if you wish to publish Gradle-generated ivy.xml descriptor files to Artifactory.

Use Maven compatible patterns

Whether to use the default Maven patterns when publishing artifacts and Ivy descriptors, or to use custom patterns. Dots in [organization] will be converted to slashes on path transformation.

Filter excluded artifacts from build Info

Add the excluded files to the excludedArtifacts list and remove them from the artifacts list in the build info.

Enable isolated resolution for downstream builds (requires Artifactory Pro

When checked, a build parameter named ARTIFACTORY_BUILD_ROOT with a value of ${JOB_NAME}-${BUILD_NUMBER} will be sent to downstream builds.

For example: ARTIFACTORY_BUILD_ROOT=Infrastructure-1025. The value of the parameter is also attached to published artifacts as the property: build.root as a matrix parameter on the deployment URL.

Downstream builds will add build.root=${ARTIFACTORY_BUILD_ROOT} as a matrix parameter to their Artifactory resolution URL

For example: build.root=Infrastructure-1025 to achieve isolated resolution from Artifactory and only resolve artifacts produced by the root build that triggered it, avoiding any artifacts produced by other runs that are out of the build chain.

Enable release management

Artifactory supports release management through the Jenkins Artifactory Plugin.

When you run your builds using Maven or Gradle with jobs that use Git or Perforce as your version control system, you can manually stage a release build allowing you to:

  • Change values for the release and next development version.
  • Choose a target staging repository for deployment of the release.
  • Create a VCS tag for the release.


Staged release builds can later be promoted or rolled-back, changing their release status in Artifactory and, optionally, moving the build artifacts to a different target repository.

Inside Artifactory, the history of all build status change activities (staged, promoted, rolled-back, etc.) is recorded and displayed for full traceability.

When release management is enabled, the Artifactory release staging link appears on the top header bar in the job page.

Build Configuration

The build Goals and options should be set to clean install

Gradle Version
The Maven version.
Tasks

Specify the Gradle task to be invoked. The artifactoryPublish task will build your Gradle project and publish your artifacts to Artifactory.


Using Default Values in the Gradle Build Script 

Behind the scenes, the Jenkins Artifactory Plugin utilises the Gradle Artifactory Plugin. It does that by injecting the Jenkins job's configuration into the artifactory closure defined by the Gradle Artifactory Plugin.

You also have the option of defining the artifactory closure in the build script with default values. When the Jenkins job is triggered, it will override these values with the values defined in the job configuration.

Since the resolution details are not defined as part of the artifactory closure in the gradle script, they cannot be overridden by the Jenkins job.



  • No labels