I have to perform a maven release from branch with Jenkis and tag the RELEASE.At the same time, i need to update the version (new SNAPSHOT) on trunk.
For Example:
/trunk contains Module_1.0.0-SNAPSHOT
/branches/Module_1.0.0-SNAPSHOT
After Perform Maven Release on /branches/Module_1.0.0-SNAPSHOT
/trunk contains Module_1.0.1-SNAPSHOT
/tag/Module_1.0.0-RELEASE
Setting maven-release-plugin and scm (url, connection, developerConnection), /tag/Module_1.0.0-RELEASE and new version on branch go right way.
But, even with developerConnection pointing to trunk doesn't udpate the version on trunk.
How could I achieve that?
thank's in advance.
If you run the Maven release plugin on your branch (/branches/Module_1.0.0-SNAPSHOT), it will:
Update the version number on this branch (1.0.0-SNAPSHOT --> 1.0.0)
Apply a tag on this branch (tag/1.0.0 or something like that)
Move your branch to 1.0.1-SNAPSHOT
Even if you set the developerConnection property, the Maven release plugin will not update the version number of your trunk branch.
If you want to increase the version number on the trunk, you have to release from the trunk (or release from the branch + merge your branch to your trunk).
Related
How to increase snapshot version or release version automatically through maven. I am aware we could use maven goals such as release:prepare or release:update-versions. But i have a scenario where my snapshot version or release version should increment automatically for each build. Should we add any custom line code in pom.. please suggest me a solution.
I have a problem with SVN. I want to commit a file (myFile.xml) from a branch and after create a tag of that branch, but when I check the new tag, myFile.xml is not modified... I will write the steps that I am doing:
1.- Checkout the branch
2.- I modify the file and commit it
3.- Checkout the branch again (to check the file and it is right)
4.- With maven mvn release:prepare and mvn release:perfom
5.- I check the new tag and myFile.xml is not modified....
What am I doing wrong??
Thank you so much.
In order for the maven release plugin to work correctly, the pom.xml must contain a
<scm>
<developerConnection>
tag, and the developerConnection must point exactly to where you want to release from.
If you created your branch "by hand" (not using the release plugin) and didn't update the developerConnection in your pom.xml, your developerConnection still points to the location you branched from (e.g. trunk).
This is for me a very hot candidate to create exactly the behaviour you describe.
I am trying to create a branch from a tag with maven but the developerConnection property is not updated. How do I do this through maven or editing the pom.xml file manually?
We use subversion for scm and maven for build/release. I want to create a branch from the latest tag (release). We will use the branch for maintenance of the code, including bug fixes, and continue developing on the trunk. (I know that discussion of developing on trunk versus on branch is involved, and I don't want to open that up.)
When I use release:branch to create the branch, the developerConnection property refers to the tag that I checked out of to create my working copy. I want it to point to the branch.
I checked out the latest tag. (foo-80.0.8)
From the command line in the working copy directory of that tag, I ran:
mvn release:branch -DbranchName=foo-80.0.8.1.x -DupdateWorkingCopyVersions=false
(The .1.x refers to the 1 st branch with x as a placeholder indicator for branch version.)
In the resulting pom.xml in the branch on the repository, the developerConnection property was set to
...Foo/tags/foo-80.0.8 (I omitted the beginning of the URL to prevent the automatic hyperlink.) I want it to be ...Foo/branches/foo-80.0.8.1.x
I tried again, but this time, I edited the pom.xml file, and changed developerConnection to ...Foo/branches/foo-80.0.8.1.x. After running mvn release:branch ..., developerConnection in the pom.xml file still pointed to the tag.
UPDATE:
I took #twomey1's suggestion. (Thanks!) Now developerConnection points to ...\tags\foo-80.0.8.1.x which is not the original tag (good), but that tag doesn't exist (bad). I checked out a fresh copy of the new branch, modified pom.xml to point to the branch, and committed the change. When I tried mvn release:prepare I got this error message:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-release-plugin:2.0-beta-7:prepare (default-cli) on
project foo: You don't have a SNAPSHOT project in the reactor projects list.
UPDATE:
#twomey1's comment about SNAPSHOT helped. Using -DupdateVersionsToSnapshot on the command line, I got release:prepare to go forward but there still seems to be confusion with tags and branches. Again, my workflow:
Run svn checkout https:.../tags/foo-80.0.8.
Run mvn -DupdateVersionsToSnapshot=true -DupdateBranchVersions=true
-DupdateWorkingCopyVersions=false -DbranchName=foo-80.0.8.1 release:branch from the working copy of the tag that was just checked out.
Run svn checkout https:.../branches/foo-80.0.8.1 from the parent directory of the working copy.
Run mvn release:prepare from the working copy of the branch that was just checked out.
Then I get a svn error passed from maven that tag foo-80.0.8.1 already exists. I want to create a release from the branch which should not conflict. The developerConnection property still points to ...\tags\foo-80.0.8.1 which doesn't exist.
UPDATE:
I repeated with this difference, I added .1 to the end of the release version, the SCM release tag, and the portion of the development version before SNAPSHOT. This seems to work. I did this during mvn release:prepare.
From the official release plugin documentation
By default, the POM in the new branch keeps the same version as the
local working copy, and the local POM is incremented to the next
revision. If you want to update versions in the new branch and not in
the working copy, run:
mvn release:branch -DbranchName=my-branch -DupdateBranchVersions=true
-DupdateWorkingCopyVersions=false
Note: This can be useful if you want to create a branch from a tag
http://maven.apache.org/maven-release/maven-release-plugin/examples/branch.html
I think you are just missing -updateBranchVersions=true from your command
We use Maven with Subversion internally. We also use Maven's Release plugin. We noticed the issue described below when running through the following (correct, I presume) steps.
1. We run release:prepare:
Maven updates the trunk version to 1.0.0.
Maven runs svn copy trunk/myproject tags/myproject-1.0.0, thus creating tag myproject-1.0.0.
Maven updates the trunk version to 1.0.1-SNAPSHOT.
2. We run release:rollback:
Maven resets the trunk version to 1.0.0-SNAPSHOT.
Maven does not remove the tag, because Maven doesn't do this kind of stuff.
3. We commit more changes to trunk, obviously against version 1.0.0-SNAPSHOT.
4. We run release:prepare again:
Maven updates the trunk version to 1.0.0.
Maven runs svn copy trunk/myproject tags/myproject-1.0.0, thinking it created tag myproject-1.0.0 out of the latest trunk. But, alas, Subversion (1.6 and 1.7 alike) will instead create tags/myproject-1.0.0/myproject on Maven's behalf.
5. We run release:perform:
Maven checks out the contents of tag myproject-1.0.0.
Maven builds the contents and deploys the result to Nexus.
The problem is obvious: the change in step 3 did not make it into the tag. We are now releasing 1.0.0 without the change in it.
The questions are: How can we fix this? Is Maven's release rollback feature inherently broken?
In fairness, rollback should reset the project and SCM to a state that allows a second prepare to occur. This includes removing the tag. The answer is now apparent (Googling "maven release rollback remove tag"):
http://maven.apache.org/maven-release/maven-release-plugin/examples/rollback-release.html:
The created branch/tag in SCM for the release is removed. Note: This
is not yet implemented so you will need to manually remove the
branch/tag from your SCM. For more info see MRELEASE-229.
The resolution would then be to force release:rollback to include a command to delete the SCM tag using something like org.codehaus.mojo:exec-maven-plugin. Short of this, wrap rollback inside a script that does that externally.
As you've discovered, release:rollback doesn't have a whole lot of utility when it doesn't clean up SCM. What our shop has done is setup our Jenkins automation to run "mvn release:prepare release:perform" in combination with the Jenkins M2 Release Plugin.
If it fails we need to delete the tag in Subversion but, then again, we would have to do this anyway with rollback.
I have a maven multi module project.
When the code is development complete, we would want to write a branch build job in Jenkins which branches the code, increment the pom versions in the trunk, and remove the
-SNAPSHOT from the pom versions in the branch.
So, if the trunk is 2.2-SNAPSHOT, by the end of the operation, the trunk should be 2.3-SNAPSHOT, and the newly created branch should have poms with 2.2.
When I use release:branch the trunk is getting updated but it's not removing the -SNAPSHOT from the poms in the branch.
Please let me know if you have any ideas of achieving this.
Thanks in advance.
From Maven Release plugin: Create a branch
By default, the POM in the new branch keeps the same version as the local working copy, and the local POM is incremented to the next revision. If you want to update versions in the new branch and not in the working copy, run:
mvn release:branch -DbranchName=my-branch -DupdateBranchVersions=true -DupdateWorkingCopyVersions=false
Note: This can be useful if you want to create a branch from a tag
As an alternative, you might want to try the Versions Maven plugin:
mvn versions:set versions:commit -DnewVersion=2.2.0
You would still need to create the branch by hand though...