I tried today to switch our release build so that it uses branches. Before my change, I just did
mvn release:prepare -B -Dusername=$SVN_USER -Dpassword=$SVN_PASSWORD -Dtag=$RELEASE_VERSION -DreleaseVersion=$RELEASE_VERSION -DdevelopmentVersion=$NEXT_DEV_VERSION
mvn release:perform
Now I changed to use
mvn release:branch -B -Dusername=$SVN_USER -Dpassword=$SVN_PASSWORD -DbranchName=$RELEASE_VERSION -DreleaseVersion=$RELEASE_VERSION -DdevelopmentVersion=$NEXT_DEV_VERSION -DautoVersionSubmodules=true -DbranchBase=$SVN_BRANCH_BASE -DdryRun=false -DsuppressCommitBeforeBranch=false -DremoteTagging=false -DupdateBranchVersions=true -DupdateVersionsToSnapshot=false -DupdateWorkingCopyVersions=true -DgenerateBackupPoms=false
then I checked that branch out and tried to perform a release on it. But this does not work, it tells me:
Unable to configure SCM repository: No such provider: 's'
SCM config is:
<scm>
<connection>scm:svn:https://svn2.mycompany.com:8443/svn/polyalert/branches/02_Los_1/releases/0.01.9</connection>
<developerConnection>scm:svn:https://svn2.cmycompany.com:8443/svn/polyalert/branches/02_Los_1/releases/0.01.9</developerConnection>
<url>https://svn2.mycompany.com:8443/svn/polyalert/branches/02_Los_1/releases/0.01.9</url>
</scm>
This url might look a bit strange, but we do not have a default layout and this is a correct branch URL.
This is done with maven 3. I´m not sure if it´s correct to do the release:perform in another location than I did the release:branch, but I don´t have a better idea, specifically because I can not set any release.properties file like it is created with release:prepare. Or would it be necessary to do the release:branch AND the release:prepare? A first try on that did not work and got the same error.
Any suggestions?
Thanks
Michael
After lots of struggle, I found the following approach working:
Ensure that your trunk has definitely correct scm info in the pom.
run mvn release:branch -B -Dusername=$SVN_USER -Dpassword=$SVN_PASSWORD -DbranchName=$RELEASE_VERSION -DreleaseVersion=$RELEASE_VERSION -DdevelopmentVersion=$NEXT_DEV_VERSION -DautoVersionSubmodules=true -DbranchBase=$SVN_BRANCH_BASE -DupdateWorkingCopyVersions=true.
This will create a branch in SVN where all versions are kept like they are in the trunk and will then increase version number in the trunk to $NEXT_DEV_VERSION and commit this as well. Branchbase can be set in the plugin configuration as well (in this case it can be omitted here).
checkout the new-made branch and change into the local branch dir
run mvn release:prepare -B -Dusername=$SVN_USER -Dpassword=$SVN_PASSWORD -Dtag=$RELEASE_VERSION -DreleaseVersion=$RELEASE_VERSION to update the release number in your branch to $RELEASE_VERSION (will be changed locally + commit into the branch by this single command). This command will on top create a release tag.
run mvn release:perform in your local branch dir to start the actual build. This will checkout the tag created in the previous step and build upon this code.
Related
We have 2 branches in github,
master
release
In our jenkins we have a job for each of these branches.
We want to increment a version number programmatically for release each time jenkins builds the release. We want also to increment the version number in the github release branch. Can you give me some directions on how to do it and what jenkin plugins i need? Thanks
This can be performed using a simple command:
mvn release:prepare release:perform --batch-mode
Explanation:
release:prepare
Prepare for a release in SCM. Steps through several phases to ensure the POM is ready to be released and then prepares SCM to eventually contain a tagged version of the release and a record in the local copy of the parameters used. It will update your version number from e.g. "1.0.1-SNAPSHOT" to "1.0.1" and commit it to the tag. Also working version will be incremented and updated to "-SNAPSHOT" again, e.g. "1.0.2-SNAPSHOT".
This can be followed by a call to release:perform. For more info see example
release:perform
Perform a release from SCM, either from a specified tag, or the tag representing the previous release in the working copy created by release:prepare. For more info see example
--batch-mode allows a non-interactive script executeion. For details please read about maven-release-plugin
Use the maven release plugin to handle incrementing the version number. At that point all you have to do is have the Jenkins build run maven with the release plugin goals.
Here is a good article on it.
http://www.vineetmanohar.com/2009/10/how-to-automate-project-versioning-and-release-with-maven/
With that all you have to do in Jenkins is have it run the following command on the checked out repository.
mvn release:prepare release:perform -B
I have this in my pom:
<scm>
<connection>scm:javasvn:http://url.com/repo/myProject/trunk</connection>
<developerConnection>scm:javasvn:http://url.com/repo/myProject/trunk</developerConnection>
<url>http://url.com/websvn/listing.php?repname=repo&path=/myProject/trunk</url>
</scm>
When I run:
mvn release:branch -DbranchName=myBranch
It creates successfully the branch here :
http://url.com/repo/myProject/branches/myBranch
But when I look into the pom.xml of this branch, the "scm" part remains the same as the trunk
<scm>
<connection>scm:javasvn:http://url.com/repo/myProject/trunk</connection>
<developerConnection>scm:javasvn:http://url.com/repo/myProject/trunk</developerConnection>
<url>http://url.com/websvn/listing.php?repname=repo&path=/myProject/trunk</url>
</scm>
Doc says:
Transform the SCM information in the POM to include the final
destination of the tag
Isn't the plugin supposed to replace "/trunk" by "/branches/myBranch"? Or are we supposed to do this manually?
The plugin replaces "trunk" by the "branches/myBranch" but don't switch your working copy. In the new created branch, viewing the remote pom.xml the scm info should have changed for that branch. maven:release fails if it cannot commit the changes.
r1643
[maven-release-plugin] prepare for next development iteration
---------------------
r1642
[maven-release-plugin] copy for branch a-project-1.0
---------------------
r1641
[maven-release-plugin] prepare branch a-project-1.0
---------------------
Is your svn log looking like this at the revision you created the branch?
In this example, r1641 changed the pom scm info from "trunk" to "branches/a-project-1.0".
r1642 copied the trunk to the branch, creating it.
r1643 changed the pom scm info from "branches/a-project-1.0" to "trunk" again so you remain at trunk in your working copy.
When I've used maven release and it failed, always has shown an error at the command line and left temporal files at my working copy that have to be deleted or cleaned with mvn --batch-mode release:clean.
Try changing your scm.url to "http://url.com/repo/myProject/trunk" instead of "http://url.com/websvn/listing.php?repname=repo&path=/myProject/trunk" (I don't think maven can change your current url parameter)
Then go again with: mvn --batch-mode -DbranchName="A_TEST" -Darguments="-DskipTests=true"
and check console errors, the svn log at the svn projects root folder, and also check for local working copy modifications.
If all should have been OK and it's not, check your maven runtime version. I've got some problems working with maven:release and maven 3.0.5 when releasing tags. I only use maven 3.1+ for branching/releasing automation purposes.
I replaced
scm:javasvn:http://...
with
scm:svn:http://...
And the transformation is done now.
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
i'm looking to release a stand-alone patch without committing it. when i prepare a release for a version i get the following error:[ERROR] fatal: Not a git repository (or any of the parent directories): .git
can i release without committing?
for now, what i'm doing is generate a jar locally and upload it manually as an artifact.
I had the same issue with mercurial. You need to use the -DpushChanges=false argument.
See my anwser to a similar question: link
If you don't want to commit anything to the SCM, I think you should try do to a dry run :
Since the Release Plugin performs a number of operations that change the project, it may be wise to do a dry run before a big release or on a new project. To do this, commit all of your files as if you were about to run a full release and run:
mvn release:prepare -DdryRun=true
This is a parameter of the release:prepare Mojo : dryRun.
I'm using Maven 2.2.1 and I sucessfully ran:
mvn -B release:clean release:prepare
But get the error message:
No SCM URL was provided to perform the release from
when I run:
mvn release:perform
My pom.xml have the scm tags defined correctly:
<scm>
<url>file:///C:/tmp/svnrepo/myproj/trunk</url>
<connection>scm:svn:file:///C:/tmp/svnrepo/myproj/trunk</connection>
<developerConnection>scm:svn:file:///C:/tmp/svnrepo/myproj/trunk</developerConnection>
</scm>
It is possible to rerun a maven release:perform by creating a manually edited release.properties file in the root folder. This file should define these two properties: scm.url and scm.tag. Here a possible example:
scm.url=scm:git:https://github.com/owner/repo.git
scm.tag=v1.0.4
With this file it is possible to redo a release:perform task.
Inspired by this answer.
Looks like I did a mvn -DdryRun=true release:perform and this had deleted the release.properties file from the prepare stage.
So I add the -DconnectionUrl to the command to provide url of the tag
It should work. I had similar problem, but in my case perform failed due to network error and I had to restart it with something like:
mvn release:perform -rf :{ARTIFACT ON WHICH IT FAILED} -DconnectionUrl=scm:svn:{URL TO TAG}
The message
No SCM URL was provided to perform the release from
does not mean the SCM URL in the pom.xml!
There are two kinds of SCM-URLS:
Trunk Folder (for development)
Tag Folder (for tagging the release)
In the pom.xml you specify the trunk-folder-url. What the release:perform require is the tag-folder-url. You can specify the parameter -DconnectionUrl.
Usually you are using prepare and perform in one maven call. Prepare do all preparation stuff and will commit some resources to the version-control-system using the comment [maven-release-plugin] prepare release XXX- BUT NOT ALL FILES ARE COMMITTED! One important file is not committed to the version-control-system, the release.properties. This file is used if you omit the -DconnectionUrl.
The problem occourse while perform because the checkout/commit require the release.properties or the -DconnectionUrl respectivly.
You can either:
Specify the tag-url by using -DconnectionUrl or
Call release:prepare release:perform in one shot to rely on the not-committed release.properties
More informations are here
I got this same exception in our CI automation and it turned out to be due to the fact that target/checkout directory already has a release build. For one of the projects, we had to introduce an improvised maven release perform build between the real maven release:prepare and release:perform steps. As part of improvisation the release tag is checked out to target/checkout and what I noticed is that if this directory is left undeleted, it would cause the release:perform to fail with the No SCM URL was provided to perform the release from error. I don't know if it matters, but we also use -DlocalCheckout=true option.
Simply running mvn release:clean release:prepare first, and then mvn release:perform worked for me.