Maven Release Plugin
  1. Maven Release Plugin
  2. MRELEASE-605

when not pushing changes to remote git repo in 2.1, the release plugin fails on release:perform

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.1
    • Fix Version/s: 2.2
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      as it tries to clone the remote repo, which has not yet been pushed - so there's no tag in the remote repo yet.

      Ideally if pushChanges is false, it should use a value of

        <scm>
           <developerConnectionL>scm:git:file://${baseDir}</developerConnection>
           ...
        </scm>
      

      so that it clones from the current local git repo (which has everything inside it) rather than the remote repo which has yet to be pushed.

      BTW a great use case for not pushing is using a staging maven repo like Nexus; which may reject an attempt to promote a staged build, so you only want to push after a downstream stage works.

        Activity

        Hide
        james strachan added a comment -

        BTW using 2.1 you can do a release using pushChanges as false. For those interested here's how I did it...

        • add the following to your pom (the version and pushChanges are the biggies)
                <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-release-plugin</artifactId>
                  <version>2.1</version>
                  <configuration>
                    <pushChanges>false</pushChanges>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <allowTimestampedSnapshots>false</allowTimestampedSnapshots>
                    <arguments>-Prelease</arguments>
                  </configuration>
                </plugin>
        
        • in your pom.xml make sure you set the scm section as follows
          <scm>
            <!-- TODO - hack this in your ~/.m2/settings.xml to point to your local checkout for releases -->
            <developerConnection>${release-altGitURL}</developerConnection>
            ...
          </scm>
        
        • in your ~/.m2/settings.xml make sure you have this...
        <settings>
          <profiles> 
            <profile>
              <id>release</id>
              <properties>
                <release-altGitURL>scm:git:file:///directory/where/my/code/is</release-altGitURL>
              </properties>
            </profile>
          </profiles>	
        
        • then when running the release plugin use
        mvn release:prepare -Prelease
        mvn release:perform -Prelease
        
        Show
        james strachan added a comment - BTW using 2.1 you can do a release using pushChanges as false. For those interested here's how I did it... add the following to your pom (the version and pushChanges are the biggies) <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.1</version> <configuration> <pushChanges> false </pushChanges> <autoVersionSubmodules> true </autoVersionSubmodules> <allowTimestampedSnapshots> false </allowTimestampedSnapshots> <arguments>-Prelease</arguments> </configuration> </plugin> in your pom.xml make sure you set the scm section as follows <scm> <!-- TODO - hack this in your ~/.m2/settings.xml to point to your local checkout for releases --> <developerConnection>${release-altGitURL}</developerConnection> ... </scm> in your ~/.m2/settings.xml make sure you have this... <settings> <profiles> <profile> <id>release</id> <properties> <release-altGitURL>scm:git:file: ///directory/where/my/code/is</release-altGitURL> </properties> </profile> </profiles> then when running the release plugin use mvn release:prepare -Prelease mvn release:perform -Prelease
        Hide
        Brett Porter added a comment -

        It shouldn't change the devConnection URL, but it should know to clone from the current directory instead if the flag is false. For git, it probably always makes sense to do this instead of wasting bandwidth cloning the repo, since it will be a clean copy.

        However, in some situations you may want the opposite - to ensure a push has occurred before performing the release. That might need to a separate check.

        Show
        Brett Porter added a comment - It shouldn't change the devConnection URL, but it should know to clone from the current directory instead if the flag is false. For git, it probably always makes sense to do this instead of wasting bandwidth cloning the repo, since it will be a clean copy. However, in some situations you may want the opposite - to ensure a push has occurred before performing the release. That might need to a separate check.
        Hide
        Brett Porter added a comment -

        btw a simpler workaround is probably to use:

        mvn release:perform -DconnectionUrl=scm:git:file:///directory/where/my/code/is
        
        Show
        Brett Porter added a comment - btw a simpler workaround is probably to use: mvn release:perform -DconnectionUrl=scm:git:file: ///directory/where/my/code/is
        Hide
        james strachan added a comment -

        Thanks - thats a much simpler workaround

        Though even better would be to just let the release plugin default to using the local repo automatically

        Show
        james strachan added a comment - Thanks - thats a much simpler workaround Though even better would be to just let the release plugin default to using the local repo automatically
        Hide
        Toni Menzel added a comment -

        Any chance seeing pushChanges=false work out of the box without the "-DconnectionUrl=scm:git:file:///directory/where/my/code/is" workaround in 2.2 ?

        Show
        Toni Menzel added a comment - Any chance seeing pushChanges=false work out of the box without the "-DconnectionUrl=scm:git: file:///directory/where/my/code/is " workaround in 2.2 ?
        Hide
        Mark Struberg added a comment -

        Hi James!

        The issue appears to be invalid. Please use <localCheckout>true if you configure <pushChanges>false.

        This will make the git clone to happen from a local file:// instead of using the upstream git:// URL.

        Please note that localCheckout currently only works with non-sparse checkouts! We are working on that in the next release.

        Show
        Mark Struberg added a comment - Hi James! The issue appears to be invalid. Please use <localCheckout>true if you configure <pushChanges>false. This will make the git clone to happen from a local file:// instead of using the upstream git:// URL. Please note that localCheckout currently only works with non-sparse checkouts! We are working on that in the next release.
        Hide
        james strachan added a comment -

        Just wanted to say a big thank you! Works like a charm. Its made one geek very happy . Just did a release without having to muck about with connectionUrl - yay!

        Show
        james strachan added a comment - Just wanted to say a big thank you! Works like a charm. Its made one geek very happy . Just did a release without having to muck about with connectionUrl - yay!

          People

          • Assignee:
            Mark Struberg
            Reporter:
            james strachan
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: