Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvn release:prepare not committing changes to pom.xml

I'm trying to release a Jenkins plugin (stashNotifier) with Maven and face a problem with the release plugin.

mvn clean release:prepare 

runs to completion without errors but fails to commit the changed pom.xml in my local git repository. Even though it does tag the HEAD of the branch on which I'm trying to release version 1.0.2. This is what my local branch looks like before preparing the release

* df60768 (HEAD, origin/develop, develop) upgraded parent pom to version 1.498 * 792766a added distribution management section to pom.xml and amended readme.md  

and this is what it looks like after

* df60768 (HEAD, tag: stashNotifier-1.0.2, origin/develop, develop) upgraded parent pom to version 1.498 * 792766a added distribution management section to pom.xml and amended readme.md  

Unfortunately, the pom.xml already contains the next development version, which in turn causes a subsequent release:perform to release that snapshot version.

From the command output of maven, it almost looks like it's omitting the git commit command:

[INFO] Checking in modified POMs... [INFO] Executing: /bin/sh -c cd /Users/gruetter/Dropbox/stashNotifier && git add -- pom.xml [INFO] Working directory: /Users/gruetter/Dropbox/stashNotifier [INFO] Executing: /bin/sh -c cd /Users/gruetter/Dropbox/stashNotifier && git status [INFO] Working directory: /Users/gruetter/Dropbox/stashNotifier [INFO] Tagging release with the label stashNotifier-1.0.2... [INFO] Executing: /bin/sh -c cd /Users/gruetter/Dropbox/stashNotifier && git tag -F /var/folders/dr/xxbtyycs1z9dl2_snlj87zrh0000gn/T/maven-scm-678409272.commit stashNotifier-1.0.2 [INFO] Working directory: /Users/gruetter/Dropbox/stashNotifier [INFO] Executing: /bin/sh -c cd /Users/gruetter/Dropbox/stashNotifier && git push [email protected]:jenkinsci/stashnotifier-plugin.git stashNotifier-1.0.2 [INFO] Working directory: /Users/gruetter/Dropbox/stashNotifier [INFO] Executing: /bin/sh -c cd /Users/gruetter/Dropbox/stashNotifier && git ls-files [INFO] Working directory: /Users/gruetter/Dropbox/stashNotifier [INFO] Transforming 'Stash Notifier'... [INFO] Not removing release POMs [INFO] Checking in modified POMs... [INFO] Executing: /bin/sh -c cd /Users/gruetter/Dropbox/stashNotifier && git add -- pom.xml [INFO] Working directory: /Users/gruetter/Dropbox/stashNotifier [INFO] Executing: /bin/sh -c cd /Users/gruetter/Dropbox/stashNotifier && git status [INFO] Working directory: /Users/gruetter/Dropbox/stashNotifier [INFO] Release preparation complete. 

I'm running maven 3.0.5 (without --dry-run or -DpushChanges=false). Here are the relevant (I think) parts of my effective pom:

[...]  <scm>    <connection>scm:git:git://github.com/jenkinsci/stashnotifier-plugin.git</connection>    <developerConnection>scm:git:[email protected]:jenkinsci/stashnotifier-plugin.git</developerConnection>    <url>https://github.com/jenkinsci/stashnotifier-plugin</url> </scm>  [...]  <distributionManagement>    <repository>       <id>maven.jenkins-ci.org</id>       <url>http://maven.jenkins-ci.org:8081/content/repositories/releases/</url>    </repository>    <snapshotRepository>       <id>maven.jenkins-ci.org</id>       <url>http://maven.jenkins-ci.org:8081/content/repositories/snapshots</url>    </snapshotRepository>    <site>      <id>github-pages</id>      <url>gitsite:[email protected]/jenkinsci/maven-site.git:plugin-parent/stashNotifier</url>    </site> </distributionManagement>  [...]  <properties>    [...]    <maven-release-plugin.version>2.2.2</maven-release-plugin.version>    [...] </properties>  [...]  <build>    [...]    <pluginManagement>       <plugins>          [...]          <plugin>             <artifactId>maven-release-plugin</artifactId>             <version>2.2.2</version>          </plugin>          [...]    </pluginManagement>     [...]     <plugins>       [...]       <plugin>          <artifactId>maven-release-plugin</artifactId>          <version>2.2.2</version>          <configuration>             <goals>deploy</goals>          </configuration>       </plugin>       [...]    </plugins> </build> 

What am I doing wrong? Thanks in advance for your insights!

like image 709
BumbleGee Avatar asked Mar 01 '13 20:03

BumbleGee


People also ask

What is Mvn release prepare?

mvn release:prepare This command prepares for a release in SCM. It goes through several phases to ensure the POM is ready to be released and then creates a tag in SVN which can be used by release:perform to make a release.

What is release prepare?

Description: 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. This can be followed by a call to release:perform .

What does Mvn Release perform do?

release:perform will fork a new Maven instance to build the checked-out project. This new Maven instance will use the same system configuration and Maven profiles used by the one running the release:perform goal.

What is SCM release tag?

scm:tag will "only" perform a tag operation on the SCM system, where release:prepare will perform various tasks, included a tag operation on the SCM system. Sometimes you only want to perform the tag operation, without all the other things the release:prepare mojo does. – Tome.


1 Answers

I solved the issue on my side (running maven 3.0.5) by updating the git scm provider dependency, not the release plugin version:

<build>   <plugins>     <plugin>       <artifactId>maven-release-plugin</artifactId>       <version>2.4.2</version>       <dependencies>         <dependency>           <groupId>org.apache.maven.scm</groupId>           <artifactId>maven-scm-provider-gitexe</artifactId>           <version>1.8.1</version>         </dependency>        </dependencies>       </plugin>     </plugins> </build> 

The git scm 1.8.1 version correctly makes the git commit (tested with the prepare and rollback goals).

EDIT: Different versions of maven-release-plugin and maven-scm-provider-gitexe may be required depending on your environment. See the comments for more discussion.

like image 157
richnou Avatar answered Sep 25 '22 14:09

richnou