I'd like to prevent Jenkins building (thus re-deploying) released versions of Maven projects. Artifactory (rightly) doesn't allow released versions to be redeployed.
I'm using a Maven profile "jenkins" for all builds run in Jenkins
Kindly note that If this Maven Project option is not visible, we need to check whether the "Maven Integration" plugin is installed in Jenkins. If not installed, then install it and restart Jenkins.
Preparing a release goes through the following release phases by default: Check that there are no uncommitted changes in the sources. Check that there are no SNAPSHOT dependencies. Change the version in the POMs from x-SNAPSHOT to a new version (you will be prompted for the versions to use)
In the Jenkins dashboard (Home screen), click Manage Jenkins from the left-hand side menu. Then, click on 'Configure System' from the right hand side. In the Configure system screen, scroll down till you see the Maven section and then click on the 'Add Maven' button.
Few examples of different project types are Freestyle, Maven, Multi-configuration, Pipeline etc. Select the "Maven Project" amongst those options, configure your project based on your requirement. And then you'll be able to see the perform maven release option to the extreme right of your jenkins dashboard.
<profile>
<id>jenkins</id>
<!-- This profile is activated by the "-P jenkins" switch when run on
the build server by Jenkins (continuous integration) -->
<build>
<plugins>
<!-- Jenkins should only build -SNAPSHOTs -->
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<evaluateBeanshell>
<condition>"${project.version}".endsWith("-SNAPSHOT")</condition>
<message>Jenkins should only build -SNAPSHOT versions</message>
</evaluateBeanshell>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With