I am looking to set up release jobs in Jenkins. We use Jenkins, Maven 3 and Perforce for source control and Nexus for repository management.
I have set up jobs with maven goals release:prepare and release:perform, however I notice that build times are doubled as both compilation and testing happens twice. My current understanding of the maven-release-plugin prepare and perform goals are as follows:
maven-release-plugin prepare:
- Ensures no local modifications to files in workspace
- Edits POMs to set release version
- Executes preparationGoals which default to
clean verify
to ensure code can be compiled and passes tests. - Commits the modified POMs
- Creates a VCS Tag
- Increments versions of POMs to next development version and commits these POMs to VCS
Also, a release.properties file is created with VCS tag and release and development version information
maven-release-plugin perform
- Checks out a fresh copy of source code using the VCS tag from the release.properties to the default location of target/checkout
- executes goals of
deploy
/deploy-site
depending on whether the project has a distributionManagement
So in order to stop doubling the build time as well as preserve build integrity, I am thinking of doing the following:
- Make jenkins checkout a fresh copy of the latest source code from source repository
- Configure the preparationsGoals config element of the release plugin to
clean deploy
- Just run
release:prepare
With the above, I think I can merge the two (prepare
and perform
) into one step and save on build turn around time. We generally always build with one build environment to target one stack (Java 6, etc) and so as long as the code successfully compiles and passes tests in the preparation step, then it is fine to deploy the artifacts to Nexus.
I am mainly looking for opposing thoughts where the above can go wrong so that I can be saved from what my eyes are blind to.
Thanks
Best Answer
This is a maven question not a Jenkins one.
In maven the prepare and perform operations do 2 different things. One operate on snapshots, the other in the tagged version of your release. One is deployed to your snapshotRepository the other to your release repository. One creates your next snapshot build, one creates your current release.
They serve different purposes. And both may be failing in their own ways depending on your maven & repository configs. Hence the need to run them both.