问题
I am using Maven Release Plugin for automate the build & release process.Its working fine but one problem I am facing.
I have created a job, which is checking trunk in every 15 minutes, if any changes found it starts the build & release process.And its working fine.
But , small problem is when the release:prepare
is executing , it is creating the tag and auto increment the trunk/pom.xml version (with SNAPSHOT) to next release version-SNAPSHOT.
Suppose my current build version is 2.0-SNAPSHOT. After successfully build it create the tag with only 2.0 (without SNAPSHOT). Also it auto increments the pom.xml inside trunk to 2.1-SNAPSHOT.
The problem is , when my Jenkins (crontab) checking the trunk in every 15 mins ,it is found a new version inside the trunk (i.e. pom.xml ). And it creates another build again. This process is happening again and again.Where I know there is no code changes in trunk, only version has incremented by release:prepare
command.
Below I am giving the screen shot of Jenkins for reference.
Any help would be appreciated.
Thanks in advance.
回答1:
Normally in Maven snapshot builds are triggered by changes in the source code and release builds are created on demand (when code is released). This is the workflow supported by the Maven release plugin.
It wasn't clear whether you also have the Jenkins M2 release plugin installed or not? It provides a convenient "Release" button to trigger release builds on your job.
回答2:
You seem to have put the release targets in the "Goals and options" section of the standard build section. This defines the build that happens when new code is checked in.
You should change "Goals and options" to something like clean deploy
(which will just deploy a snapshot to your remote repository.
You should then click the checkbox "Maven release build" under the "Build Environment" section. It will be pre-populated with the standard release commands. These commands will be run only when you click on the "Perform Maven Release" button on the job front page.
来源:https://stackoverflow.com/questions/18778986/how-to-automate-a-job-in-jenkins