mvn release:prepare not committing changes to pom.

2020-01-26 04:37发布

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? Thanks in advance for your insights!

9条回答
男人必须洒脱
2楼-- · 2020-01-26 05:04

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!

查看更多
趁早两清
3楼-- · 2020-01-26 05:05

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.

查看更多
啃猪蹄的小仙女
4楼-- · 2020-01-26 05:09

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.

查看更多
登录 后发表回答