Parallel Maven Deployment with Jenkins and Artifactory
There are many reasons why you may want to use Artifactory as your Maven repository. For example, it allows tagging Maven artifacts with custom properties, so that they can later be found based on specific criteria. It stores build metadata about your artifacts, and allows controlling the repositories used by the Maven build, without modifying the pom file. In this post, I’d like to focus on one specific advantage, Maven deployments in Jenkins.
Reduce Maven Build Time with Parallel Deployment
JFrog has recently released version 3.6.1 of the Jenkins Artifactory Plugin. This release includes a significant enhancement when it comes to Maven deployments – it is now parallel! You now have the option of setting the number of threads assigned to the deployment of Maven artifacts.
This should actually reduce the build time dramatically, especially if your build creates and deploys a large amount of artifacts.
If you’re already using the plugin to build your code, after upgrading the Artifactory Plugin, without changing any of your build configuration, the deployment time should be reduced to a third of what it used to be. By default, Jenkins will use three threads of the deployment, but you have the option of changing this default from within your pipeline code.
If you’re already using the Artifactory pipeline APIs, then your script should include this section, which defines the Maven deployment using declarative syntax. Notice the new threads property which is now supported.
rtMavenDeployer (
id: 'deployer-unique-id',
serverId: 'Artifactory-1',
releaseRepo: 'libs-release-local',
snapshotRepo: 'libs-snapshot-local',
threads: 6 // The default value is 3
)
If you’re using the scripted syntax, you can set the threads count on the deployer as follows:
rtMaven.deployer.threads = 6
Read more about Maven builds with Jenkins and Artifactory, and get started with the latest version of the Jenkins Artifactory Plug-in.