4
votes

We have a Gradle project in a Git repository that Jenkins monitors for commits. When a new commit comes in it kicks off the build pipeline. At the end of the pipeline it publishes the jar file to Artifactory.

I want Jenkins to use the Git SHA commit ID has the artifact version number of the published jar. I see that the Jenkins Git plugin saves the commit ID in an environment variable called GIT_COMMIT. But how do I tell the Jenkins Artifactory plugin to use this value for the version number?

1

1 Answers

4
votes

You don't have to abuse the file name with additional metadata, since Artifactory knows how to store the metadata for the files.

More so, all the files built by Jenkins with Jenkins Artifactory plugin, or with Gradle with Gradle Artifactory plugin already have this information.

Here's an example of the properties passed by Jenkins to Arifactory. As you can see, the vcs.revision includes the information you need: enter image description here