Search code examples
javagitmavenjenkinsartifactory

Publish Maven build to Artifactory from Jenkins


I have a build setup in Jenkins, which compiles a simple Git hosted Maven project into a jar and publishes the jar into Artifactory.

  1. How can I setup the build job to tag the sources which were used for the build with e.g. a build number (or similar), in order to later be able to identify which sources went exactly into this particular build. This build tag should also be visible in git's remote repository, not just in the local version on the Jenkins build server.

  2. Ideally I'd also like to package this "build tag" into the jar (I suppose in a file inside the jar) so I can always correlate the jar to which source files were used to create this jar.

Your help is much appreciated.


Solution

  • Just use the Jenkins Artifactory Plugin or the Maven Artifactory Plugin.

    Both generate a BuildInfo metadata that include the information you need and much, much more. All this information is attached to the artifacts and make the artifacts traceble without need to embed this info in the filenames or into the archives themselves.

    Please take some time to watch this screencast. It explains in detail what you can get and why it's important.