Maven SCM (moved to ASF)
  1. Maven SCM (moved to ASF)
  2. SCM-444

Git provider does 'git push' during 'mvn release:prepare' which causes unwanted problems

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.4
    • Component/s: maven-scm-provider-git
    • Labels:
      None
    • Complexity:
      Intermediate
    • Number of attachments :
      2

      Description

      When doing 'mvn release:prepare' with a Git provider, a 'git push' command is executed. This is not ideal because the push command can fail or push things from the local repository that are not needed/wanted in the remote repository. Some examples are:

      1. The local repository has two branches: master (tracking origin/master) and dummy (tracking origin/dummy). The release is being made on the master branch, and the dummy and origin/dummy branches have diverged. Running 'release:prepare' causes a 'git push', which will succeed for the master branch (assuming that the release preparation has been made correctly) and fail for the dummy branch (the two branches have diverged and need to be merged or rebased). The release preparation aborts and the directory is left in a somewhat inconsistent state where manual cleaning up is needed (removing pom.xml.next files, changing versions to <new>-SNAPSHOT, etc.)

      2. The local repository has two branches: master (tracking origin/master) and localtest (not in the origin repository). The localtest branch shouldn't be published because it is just used for some temporary testing and doesn't even work. It will be pushed during 'release:prepare'.

      Suggested behaviour: use 'git push origin <currentbranch>:<currentbranch>', or even better, query for which remote repository to push to (found in .git/config) and which branch to push from and to. For me, it would be great to have a 'confirm push' before doing it so as to keep things clean, but maybe that is quite complex.

      1. SCM-444.patch
        8 kB
        Hiram Chirino
      1. release_branch.jpg
        23 kB

        Issue Links

          Activity

          Hide
          Olivier Lamy added a comment -

          have a look at http://maven.apache.org/plugins/maven-release-plugin/prepare-mojo.html#allowTimestampedSnapshots
          and maven probably ask you if you are sure about using SNAPSHOT for your release

          Show
          Olivier Lamy added a comment - have a look at http://maven.apache.org/plugins/maven-release-plugin/prepare-mojo.html#allowTimestampedSnapshots and maven probably ask you if you are sure about using SNAPSHOT for your release
          Hide
          Marcin Zajaczkowski added a comment -

          Thanks Olivier for a quick reply. That helped .
          allowTimestampedSnapshots works fine for me.

          Show
          Marcin Zajaczkowski added a comment - Thanks Olivier for a quick reply. That helped . allowTimestampedSnapshots works fine for me.
          Hide
          Johannes Schneider added a comment -

          Just wanna make clear, that version 2.1 of the release plugin has been released some time ago. So no need to use the Snapshot version....

          Show
          Johannes Schneider added a comment - Just wanna make clear, that version 2.1 of the release plugin has been released some time ago. So no need to use the Snapshot version....
          Hide
          Antony Stubbs added a comment -

          Is it just me, or it this totally ignored? Or have a new bug...

          ~/k/l/j/KREST (master) $ mvn release:prepare  -DpushChanges=false -DlocalCheckout=true -DremoteTagging=false
          [INFO] Scanning for projects...
          
          <snip>
          
          [INFO] [INFO] ------------------------------------------------------------------------
          [INFO] Checking in modified POMs...
          [INFO] Executing: /bin/sh -c cd /Users/antony/knewton/lib/java/KREST && git add -- pom.xml
          [INFO] Working directory: /Users/antony/knewton/lib/java/KREST
          [INFO] Executing: /bin/sh -c cd /Users/antony/knewton/lib/java/KREST && git status
          [INFO] Working directory: /Users/antony/knewton/lib/java/KREST
          [INFO] Tagging release with the label krest-3.1.0...
          [INFO] Executing: /bin/sh -c cd /Users/antony/knewton/lib/java/KREST && git tag -F /var/folders/vn/3wgr1b_s66s22sq__v7gw_g00000gp/T/maven-scm-670890544.commit krest-3.1.0
          [INFO] Working directory: /Users/antony/knewton/lib/java/KREST
          [INFO] Executing: /bin/sh -c cd /Users/antony/knewton/lib/java/KREST && git push ssh://git.knewton.net:29418/lib/java/KREST krest-3.1.0
          [INFO] Working directory: /Users/antony/knewton/lib/java/KREST
          [INFO] ------------------------------------------------------------------------
          [INFO] BUILD FAILURE
          [INFO] ------------------------------------------------------------------------
          [INFO] Total time: 26.407 s
          [INFO] Finished at: 2014-10-23T10:31:44-04:00
          [INFO] Final Memory: 15M/96M
          [INFO] ------------------------------------------------------------------------
          [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.2:prepare (default-cli) on project krest: Unable to tag SCM
          [ERROR] Provider message:
          [ERROR] The git-push command failed.
          [ERROR] Command output:
          [ERROR] To ssh://git.knewton.net:29418/lib/java/KREST
          [ERROR] ! [rejected]        krest-3.1.0 -> krest-3.1.0 (already exists)
          [ERROR] error: failed to push some refs to 'ssh://git.knewton.net:29418/lib/java/KREST'
          [ERROR] hint: Updates were rejected because the tag already exists in the remote.
          [ERROR] -> [Help 1]
          [ERROR]
          [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
          [ERROR] Re-run Maven using the -X switch to enable full debug logging.
          [ERROR]
          [ERROR] For more information about the errors and possible solutions, please read the following articles:
          [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
          
          Show
          Antony Stubbs added a comment - Is it just me, or it this totally ignored? Or have a new bug... ~/k/l/j/KREST (master) $ mvn release:prepare -DpushChanges= false -DlocalCheckout= true -DremoteTagging= false [INFO] Scanning for projects... <snip> [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Checking in modified POMs... [INFO] Executing: /bin/sh -c cd /Users/antony/knewton/lib/java/KREST && git add -- pom.xml [INFO] Working directory: /Users/antony/knewton/lib/java/KREST [INFO] Executing: /bin/sh -c cd /Users/antony/knewton/lib/java/KREST && git status [INFO] Working directory: /Users/antony/knewton/lib/java/KREST [INFO] Tagging release with the label krest-3.1.0... [INFO] Executing: /bin/sh -c cd /Users/antony/knewton/lib/java/KREST && git tag -F / var /folders/vn/3wgr1b_s66s22sq__v7gw_g00000gp/T/maven-scm-670890544.commit krest-3.1.0 [INFO] Working directory: /Users/antony/knewton/lib/java/KREST [INFO] Executing: /bin/sh -c cd /Users/antony/knewton/lib/java/KREST && git push ssh: //git.knewton.net:29418/lib/java/KREST krest-3.1.0 [INFO] Working directory: /Users/antony/knewton/lib/java/KREST [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 26.407 s [INFO] Finished at: 2014-10-23T10:31:44-04:00 [INFO] Final Memory: 15M/96M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.2:prepare ( default -cli) on project krest: Unable to tag SCM [ERROR] Provider message: [ERROR] The git-push command failed. [ERROR] Command output: [ERROR] To ssh: //git.knewton.net:29418/lib/java/KREST [ERROR] ! [rejected] krest-3.1.0 -> krest-3.1.0 (already exists) [ERROR] error: failed to push some refs to 'ssh: //git.knewton.net:29418/lib/java/KREST' [ERROR] hint: Updates were rejected because the tag already exists in the remote. [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch . [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http: //cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
          Hide
          Johannes Schneider added a comment -

          I am using jgitflow since some time. Mich better workflow for git based releases...

          Show
          Johannes Schneider added a comment - I am using jgitflow since some time. Mich better workflow for git based releases...

            People

            • Assignee:
              Olivier Lamy
              Reporter:
              Petter Måhlén

              Dates

              • Created:
                Updated:
                Resolved: