84

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 git@github.com: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:git@github.com: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:git@github.com/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?

starball
  • 20,030
  • 7
  • 43
  • 238
BumbleGee
  • 2,031
  • 3
  • 18
  • 18
  • Unfortunately i dont see any error message which is related to your decription. Can you show the error messages you get? – khmarbaise Mar 02 '13 at 12:47
  • 3
    That's the thing; there are no error messages at all. Are you interested in a particular section of the output? (I'd like to avoid bloating the question by appending the multi-page maven command line output) – BumbleGee Mar 03 '13 at 14:04
  • I just had the exact same problem and solved it by updating to version 2.4 of maven-release-plugin. – brk3 Mar 06 '13 at 21:41
  • I also had the same problem, only I fixed it by downgrading from version 2.4 to 2.3.2. Go figure. – Greg Case Mar 21 '13 at 14:17
  • 2
    I also had the problem, but upgrading from 2.4.1 to 2.5.1 solved it for me. – John Fear Mar 12 '15 at 09:47
  • I'm seeing this exact problem (now 9 years later). Several versions have passed since 2013-2015 timeframe. I'm wondering what the root of the problem is. I've added the `-X` option to produce a bunch of output but now looking for what a normal output looks like. – PatS Oct 06 '22 at 16:58

9 Answers9

96

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.

sffc
  • 6,186
  • 3
  • 44
  • 68
richnou
  • 961
  • 6
  • 3
  • 1
    This solved my git issue with maven-release-plugin 2.4.2. Very nice. – kevinarpe Feb 03 '14 at 12:24
  • This solved the problem for me too - please award the answer to @richnou so he can receive his credit! – Les Hazlewood Feb 18 '14 at 23:00
  • Works under maven 2.2.1 as well. – jaydfwtx Jul 15 '14 at 20:30
  • If I could +10, I would, this problem has been driving me nuts for so long. – Jack Leow Aug 12 '14 at 18:01
  • 3
    @BumbleGee, you should consider accepting this answer! – ericbn Sep 28 '14 at 15:26
  • Thanks! Had the same issue with release plugin 2.5.1, downgrade to 2.4.2 + git scm 1.8.1 solves the problems! – Laimoncijus Feb 27 '15 at 10:46
  • had the same problem after we moved the project to git, the plugin was fine when the project was in svn. after adding the maven-scm-provider-gitexe dependency it started to work. thanks! – Rudi Mar 13 '15 at 14:00
  • instead of this specific dependency I updated all of it to `maven-scm-plugin1.9.4` – xenoterracide Jul 05 '15 at 02:44
  • Is fixed in 2.5.2 without the workaround. Thanks for suggesting the solution till 2.5.2. – raisercostin Aug 16 '15 at 15:54
  • 2
    It's not fixed with maven-release-plugin2.5.2 and if you define the maven-release-plugin dependency to latest released version (1.9.4) of maven-scm-provider-gitexe . I changed the release-plugin dep.. to 1.8.1 and everything worked nice. – Tobias Hochgürtel Sep 01 '15 at 19:54
  • 3
    I'll second @TobiasHochgürtel. Combo of 2.5.2 & 1.9.4 still has a bug. 2.5.2 & 1.8.1 seems ok. – kenny Sep 02 '15 at 05:06
  • I asked on Maven Developer Mailinglist for an changed behavior and they hint me to an Jira Issue [MRELEASE-812](https://issues.apache.org/jira/browse/MRELEASE-812) and [my Mailinglist Thread](http://mail-archives.apache.org/mod_mbox/maven-dev/201509.mbox/browser). I hope I can activate some users from here to provide feedback to the maven developers. – Tobias Hochgürtel Sep 02 '15 at 10:04
  • Did exactly as the this answer - solved my problems. 5 hours of struggle I'm not getting back. Thanks maven/git/gitlab. – demaniak Oct 06 '15 at 14:36
  • 4
    I still had the problem that the changes in the POMs were not commited with Maven 3.3.1, maven-release-plugin 2.4.1 and maven-scm-provider-gitexe 1.9. Updating to maven-release-plugin 2.5.3 and maven-scm-provider-gitexe 1.9.4 solved the issue. – Sven Ackermann May 31 '16 at 06:40
  • I had this same problem for a multi-module project using Maven 3.0.4, and didn't have a block for the maven-release-plugin in my parent pom.xml at all. I added the block you show above to the parent pom.xml, updated the maven-release-plugin version to 2.5.2, left maven-scm-provider-gitexe at 1.8.1, and it fixed my problem. Thank you! – Schmick Oct 05 '16 at 20:35
  • Available versions for maven release plugin can be found [here](https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-release-plugin) and versions for gitexe can be found [here](https://mvnrepository.com/artifact/org.apache.maven.scm/maven-scm-provider-gitexe) – andrzej.szmukala Jun 08 '17 at 09:29
  • Running Maven 3.5.2. I am using maven-release-plugin 2.5.3 and maven-scm-plugin 1.9.5, but had to add dependency maven-scm-provider-gitexe 1.8.1, to the release-plugin. No other combinations I tried worked for me. – Avec May 16 '18 at 14:45
  • Update to my comment above. This only work for one pom and no submodules. If submodules the poms is not commited. – Avec May 23 '18 at 07:46
  • 1
    [SCM-815](https://issues.apache.org/jira/browse/SCM-815?jql=project%20%3D%20SCM%20AND%20text%20~%20%22commit%22) seems to be a factor in my case. I am on windows but have [Babun](http://babun.github.io/) (Cygwin) as prefered bash. When using Windows Shell I can use scm-plugin 1.9.5 and no need for scm-provider-gitexe 1.8.1. – Avec May 23 '18 at 10:06
  • This issue is relevant in 2020, I got the exact problem in Spring boot 2.3.1 project and git version 2.27.0 and this solution proposed by richnou fixed it. Also I added the tag in format as desired by Spring boot 2.3.1 – spujap Aug 28 '20 at 06:49
  • For maven-release-plugin:2.5.3 (maven 3.8.5 and git 2.37) it works with maven-scm-provider-gitexe:1.13.0. I also had to add maven-scm-api:1.13.0 to make it work. Let's hope the upcoming version 3 will fix this... – Olaf Ziems Sep 19 '22 at 13:14
18

I ran into the same problem, solution by #richnou works for me (upgrading SCM dependency). There is the issue created on this problem, see link below. The problem relates with new version of Git where "git status" returns localized messages which plugin cannot parse. It is the root cause. The issue was fixed in git scm (1.8.1 version) by using --porcelain option of git (which should return easily parsable output), but after this fix, another problem has raised - if repository root (scm tag) is not the working directory, release:prepare still fails. This issue seems to be fixed in snapshot version of Git SCM (not released yet). This can be workarounded by copiing scm tag into child pom.

MRELEASE-812

SCM-709

maven-release-plugin-and-git-fix

Javier
  • 12,100
  • 5
  • 46
  • 57
vasekt
  • 2,055
  • 2
  • 17
  • 13
  • 1
    I also had the same issue. I've maven 3.2.1 and git 1.9.1. Just updating release plugin to 2.5 didn't work for me because the directory I had the pom was not the git root. As richnou suggested I updated the maven-scm-provider-gitexe to latest one which was 1.9.2 and it solved the problem. – Chathurika Sandarenu Nov 19 '14 at 10:15
12

Firstly, the answers from richnou and vasekt solved my problem I thought I'd post this answer just because of newer versions than have been mentioned and I thought it would be good to give an extra example including them.

I was running maven release plugin 2.3.2 with Git 3.3.x without specifying the maven scm dependency version, which was causing the snapshot issue. For me I just upgraded to the latest version at the time for both maven release plugin and the scm dependency which were as follows:

<plugin>
   <artifactId>maven-release-plugin</artifactId>
   <version>2.5.3</version>
   <dependencies>
      <dependency>
         <groupId>org.apache.maven.scm</groupId>
         <artifactId>maven-scm-provider-gitexe</artifactId>
         <version>1.9.5</version>
      </dependency>
   </dependencies>
</plugin>

This worked fine for me, release versions uploaded properly to the release repo and the snapshot worked as expected as well.

Jeremy
  • 3,418
  • 2
  • 32
  • 42
  • 2
    In my case I only had to upgrade maven-release-plugin to 2.5.3. It wasn't necessary to specify the gitexe dependency. – colini Oct 18 '17 at 14:48
  • 1
    Maven 3.5.2, Maven-release-plugin 2.5.3 + provider 1.9.5 does not commit the pom's after mvn release:prepare for me. provider 1.8.1 does however. – Avec May 16 '18 at 16:06
  • Update to my comment above. 1.8.1 works for commiting single pom project but not for multi module projects. – Avec May 23 '18 at 07:47
9

You are probably reading this because the above solutions have not worked for you. I had the same issue and I tried everything mentioned here. My versions were: maven-release-plugin 2.5 and git 1.7.9

The solution that worked for me was downgrading maven-release-plugin to version 2.3.2

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <autoVersionSubmodules>true</autoVersionSubmodules>
            </configuration>
        </plugin>
    </plugins>
</build>
Iulian Ghionoiu
  • 366
  • 3
  • 5
  • 4
    I had `maven-release-plugin-2.3.2` and git v1.9.3 and upgrading to `maven-release-plugin-2.5` fixed it for me. – Sean Connolly Oct 23 '14 at 20:05
  • I had `maven-release-plugin-2.3.1` and git `1.9.4` and upgrading to `maven-release-plugin-2.5` also worked for me. – Welsh Nov 18 '14 at 19:45
  • 1
    Upgrading the plugin to `2.5.2` solved the problem for me, with git `2.4.0` – JBCP Sep 10 '15 at 00:59
  • 1
    perhaps it's a git version / mvn version interlock issue. Why does the latest maven (3.3.9) still default the release plugin to 2.3.2? Is this a maven bug? http://maven.apache.org/ref/3.3.9/maven-model-builder/super-pom.html – Steven R. Loomis Jul 13 '16 at 16:58
4

Upgrading the maven-release-plugin to 2.5.2 helped (upgrading to 2.5 didn’t; it works for some people but not all, possibly depending on other newer software on the system). I believe it automatically pulls in the new provider.

mirabilos
  • 5,123
  • 2
  • 46
  • 72
1

I just ran into this same problem, and from the other answers and comments, figured it was likely a bug in the release plugin itself.

In my case, I was using version 2.4 of the plugin with git in a new-and-mostly-empty project structured as follows:

my-repo.git/
  module-parent/     # running the release from here
  (module-child-1/)  # except I hadn't created it yet
  (module-child-2/)  # except I hadn't created it yet

(The source code for this project can be seen here, before resolving the problem: my project with the same problem.)

Looking at the release notes for maven-release-plugin:2.4.1, it seemed like perhaps MRELEASE-830 had a shot of resolving it.

I'm not sure if that actually was the problem, but upgrading my project to 2.4.1 of the plugin resolved it for me. Hope it resolves the problem for you, too!

Karl M. Davis
  • 606
  • 1
  • 7
  • 22
1

I encountered this same problem when using cygwin+maven+git. It showed no errors but did not attempt to commit the pom changes, just stopped after git status:

[INFO] Checking in modified POMs...
[INFO] Executing: cmd.exe /X /C "git add -- pom.xml"
[INFO] Working directory: C:\Users\ltheisen\git\caasd-portal-automation
[INFO] Executing: cmd.exe /X /C "git status"
[INFO] Working directory: C:\Users\ltheisen\git\caasd-portal-automation
[INFO] Tagging release with the label portal-automation-0.3.9...
[INFO] Executing: cmd.exe /X /C "git tag -F C:\cygwin64\tmp\maven-scm-1212196933.commit portal-automation-0.3.9"
[INFO] Working directory: C:\Users\ltheisen\git\caasd-portal-automation
[INFO] Executing: cmd.exe /X /C "git push git@barrel.mitre.org:org-mitre-caasd/portal-automation.git portal-automation-0.3.9"
[INFO] Working directory: C:\Users\ltheisen\git\caasd-portal-automation
[INFO] Executing: cmd.exe /X /C "git ls-files"
[INFO] Working directory: C:\Users\ltheisen\git\caasd-portal-automation
[INFO] Transforming 'portal-automation'...
[INFO] Not removing release POMs
[INFO] Checking in modified POMs...
[INFO] Executing: cmd.exe /X /C "git add -- pom.xml"
[INFO] Working directory: C:\Users\ltheisen\git\caasd-portal-automation
[INFO] Executing: cmd.exe /X /C "git status"
[INFO] Working directory: C:\Users\ltheisen\git\caasd-portal-automation
[INFO] Release preparation complete.

As you can see, no errors, just didn't commit after checking status. However when I ran from windows command prompt instead:

...
[INFO] Executing: cmd.exe /X /C "git add -- pom.xml"
[INFO] Working directory: C:\Users\ltheisen\git\caasd-portal-automation
[INFO] Executing: cmd.exe /X /C "git status"
[INFO] Working directory: C:\Users\ltheisen\git\caasd-portal-automation
[INFO] Executing: cmd.exe /X /C "git commit --verbose -F C:\Users\ltheisen\AppData\Local\Temp\maven-scm-2030091036.commit pom.xml"
[INFO] Working directory: C:\Users\ltheisen\git\caasd-portal-automation
[INFO] Executing: cmd.exe /X /C "git symbolic-ref HEAD"
[INFO] Working directory: C:\Users\ltheisen\git\caasd-portal-automation
[INFO] Executing: cmd.exe /X /C "git push git@barrel.mitre.org:org-mitre-caasd/portal-automation.git master:master"
[INFO] Working directory: C:\Users\ltheisen\git\caasd-portal-automation
[INFO] Release preparation complete.

You can see that it did commit after checking the status. Not sure if this is your issue as well, but it worked for me.

Note that this would mean you need to install msysgit

Lucas
  • 14,227
  • 9
  • 74
  • 124
1

I'm using Git 1.8.x locally and ran into similar problem:

maven-scm-plugin does

$ git add
$ git status

but no

$ git commit

Use another machine with Git 1.7.x helped me to work around this issue.

Note: I tried using maven-scm-plugin 1.8.1 or 1.9, maven-release-plugin 2.4.1 or 2.4.2.

Lukas Fryc
  • 131
  • 4
0

Similar issue, but I had this problem, using Jenkins Release Plugin and Gitlab:

  • First time it worked.
  • Second time it wouldn't commit.

Turns out we had a typo in SCM config in our pom.xml, so the Project with typo got created on the first time. At the second time, Maven was accessing the outdated project and complained, not committing the changes.

exic
  • 2,220
  • 1
  • 22
  • 29