aleksandr-m / gitflow-maven-plugin

The Git-Flow Maven Plugin supports various Git workflows, including GitFlow and GitHub Flow. This plugin runs Git and Maven commands from the command line.
https://aleksandr-m.github.io/gitflow-maven-plugin/
Apache License 2.0
488 stars 180 forks source link

Unable to release from develop to master #331

Closed robross0606 closed 2 years ago

robross0606 commented 2 years ago

We have a very simple "mock" gitflow project we're attempting to prove out with this plugin via Jenkins and Bitbucket. When we run a release build via Jenkins, it calls:

withMaven(maven: 'Maven_3.6.0') {
  echo 'Publishing release artifact...'
  sh 'mvn -B gitflow:release'
}

Our pom.xml file has:

<plugin>
    <groupId>com.amashchenko.maven.plugin</groupId>
    <artifactId>gitflow-maven-plugin</artifactId>
    <version>1.17.0</version>
    <configuration>
        <gitFlowConfig>
            <versionTagPrefix>v</versionTagPrefix>
        </gitFlowConfig>
        <verbose>true</verbose>
        <releaseMergeFFOnly>true</releaseMergeFFOnly>
    </configuration>
</plugin>

We create a merge request from develop to master which triggers the release build. For some reason, the plugin errors with a fairly vague message:

[2022-02-11T14:50:08.401Z] [INFO] --- gitflow-maven-plugin:1.17.0:release (default-cli) @ mock-java-shared-library ---
[2022-02-11T14:50:09.312Z] [INFO] Checking for uncommitted changes.
[2022-02-11T14:50:09.563Z] [INFO] Local branch 'develop' doesn't exist. Trying to fetch and check it out from 'origin'.
[2022-02-11T14:50:09.563Z] [INFO] Fetching remote branch 'origin develop'.
[2022-02-11T14:50:09.563Z] [WARNING] There were some problems fetching remote branch 'origin develop'. You can turn off remote branch fetching by setting the 'fetchRemote' parameter to false.
[2022-02-11T14:50:09.563Z] [INFO] Creating a new branch 'develop' from 'origin/develop' and checking it out.
[2022-02-11T14:50:09.563Z] [INFO] ------------------------------------------------------------------------
[2022-02-11T14:50:09.563Z] [INFO] BUILD FAILURE
[2022-02-11T14:50:09.563Z] [INFO] ------------------------------------------------------------------------
[2022-02-11T14:50:09.563Z] [INFO] Total time:  1.499 s
[2022-02-11T14:50:09.563Z] [INFO] Finished at: 2022-02-11T14:50:09Z
[2022-02-11T14:50:09.563Z] [INFO] ------------------------------------------------------------------------
[2022-02-11T14:50:09.563Z] [INFO] [jenkins-event-spy] Generated /var/lib/jenkins/workspace/_mock-java-shared-library_master@tmp/withMaven9fd2a0b6/maven-spy-20220211-145007-6598075854275732752913.log
[2022-02-11T14:50:09.563Z] [ERROR] Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.17.0:release (default-cli) on project mock-java-shared-library: release: fatal: 'origin/develop' is not a commit and a branch 'develop' cannot be created from it -> [Help 1]
[2022-02-11T14:50:09.563Z] [ERROR] 
[2022-02-11T14:50:09.563Z] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[2022-02-11T14:50:09.563Z] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[2022-02-11T14:50:09.563Z] [ERROR] 
[2022-02-11T14:50:09.563Z] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[2022-02-11T14:50:09.563Z] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
script returned exit code 1

It is difficult to understand what "some problems" means and we already have verbose set to true. Any advice on what may be wrong with this setup? We absolutely have an origin/develop branch since this is the source of the PR: image

robross0606 commented 2 years ago

I also tried with gitflow:release-start and `gitflow which yielded basically the same error:

[2022-02-11T15:25:41.565Z] + mvn -B gitflow:release-start gitflow:release-finish
[2022-02-11T15:25:41.565Z] ----- withMaven Wrapper script -----
[2022-02-11T15:25:41.565Z] Picked up JAVA_TOOL_OPTIONS: -Dmaven.ext.class.path="/var/lib/jenkins/workspace/_mock-java-shared-library_master@tmp/withMavenbcb7efa9/pipeline-maven-spy.jar" -Dorg.jenkinsci.plugins.pipeline.maven.reportsFolder="/var/lib/jenkins/workspace/_mock-java-shared-library_master@tmp/withMavenbcb7efa9" 
[2022-02-11T15:25:41.815Z] Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T18:41:47Z)
[2022-02-11T15:25:41.815Z] Maven home: /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.6.0
[2022-02-11T15:25:41.815Z] Java version: 11.0.2, vendor: Oracle Corporation, runtime: /var/lib/jenkins/tools/hudson.model.JDK/jdk11/jdk-11.0.2
[2022-02-11T15:25:41.815Z] Default locale: en_US, platform encoding: UTF-8
[2022-02-11T15:25:41.815Z] OS name: "linux", version: "4.14.262-135.489.amzn1.x86_64", arch: "amd64", family: "unix"
[2022-02-11T15:25:43.159Z] [INFO] [jenkins-event-spy] Generate /var/lib/jenkins/workspace/_mock-java-shared-library_master@tmp/withMavenbcb7efa9/maven-spy-20220211-152542-93112851724635433303219.log.tmp ...
[2022-02-11T15:25:43.410Z] [INFO] Scanning for projects...
[2022-02-11T15:25:43.660Z] [INFO] 
[2022-02-11T15:25:43.660Z] [INFO] -------------< com.mycompany.mock:mock-java-shared-library >--------------
[2022-02-11T15:25:43.660Z] [INFO] Building Mock Java Shared Library 0.0.1-SNAPSHOT
[2022-02-11T15:25:43.660Z] [INFO] --------------------------------[ jar ]---------------------------------
[2022-02-11T15:25:43.660Z] [INFO] 
[2022-02-11T15:25:43.661Z] [INFO] --- gitflow-maven-plugin:1.17.0:release-start (default-cli) @ mock-java-shared-library ---
[2022-02-11T15:25:45.005Z] [INFO] Checking for uncommitted changes.
[2022-02-11T15:25:45.005Z] [INFO] Local branch 'develop' doesn't exist. Trying to fetch and check it out from 'origin'.
[2022-02-11T15:25:45.005Z] [INFO] Fetching remote branch 'origin develop'.
[2022-02-11T15:25:45.005Z] [WARNING] There were some problems fetching remote branch 'origin develop'. You can turn off remote branch fetching by setting the 'fetchRemote' parameter to false.
[2022-02-11T15:25:45.005Z] [INFO] Creating a new branch 'develop' from 'origin/develop' and checking it out.
[2022-02-11T15:25:45.005Z] [INFO] ------------------------------------------------------------------------
[2022-02-11T15:25:45.005Z] [INFO] BUILD FAILURE
[2022-02-11T15:25:45.005Z] [INFO] ------------------------------------------------------------------------
[2022-02-11T15:25:45.005Z] [INFO] Total time:  1.625 s
[2022-02-11T15:25:45.005Z] [INFO] Finished at: 2022-02-11T15:25:44Z
[2022-02-11T15:25:45.005Z] [INFO] ------------------------------------------------------------------------
[2022-02-11T15:25:45.005Z] [INFO] [jenkins-event-spy] Generated /var/lib/jenkins/workspace/_mock-java-shared-library_master@tmp/withMavenbcb7efa9/maven-spy-20220211-152542-93112851724635433303219.log
[2022-02-11T15:25:45.005Z] [ERROR] Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.17.0:release-start (default-cli) on project mock-java-shared-library: fatal: 'origin/develop' is not a commit and a branch 'develop' cannot be created from it -> [Help 1]
[2022-02-11T15:25:45.005Z] [ERROR] 
[2022-02-11T15:25:45.005Z] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[2022-02-11T15:25:45.005Z] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[2022-02-11T15:25:45.005Z] [ERROR] 
[2022-02-11T15:25:45.005Z] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[2022-02-11T15:25:45.005Z] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
script returned exit code 1
aleksandr-m commented 2 years ago

I've added more logs for verbose mode. As for the reason, do you need fetching in that case at all? Maybe set fetchRemote to false. You can try running git fetch directly and see the output.

alapierre commented 1 year ago

I had similar error in Bitbucket Pipelines:

[INFO] --- gitflow-maven-plugin:1.19.0:release-finish (default-cli) @ ................. ---
[INFO] Checking for uncommitted changes.
[INFO] Checking out 'release/2.2.2' branch.
[INFO] Checking for SNAPSHOT versions in dependencies.
[INFO] Fetching remote from 'origin'.
[INFO] Fetching remote from 'origin'.
[INFO] Comparing local branch 'development' with remote 'origin/development'.
[INFO] Fetching remote from 'origin'.
[INFO] Local branch 'master' doesn't exist. Trying check it out from 'origin'.
[INFO] Creating a new branch 'master' from 'origin/master' and checking it out.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.305 s
[INFO] Finished at: 2023-04-03T07:49:32Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.19.0:release-finish (default-cli) on project ksef-integration-service-multitenant: release-finish: fatal: 'origin/master' is not a commit and a branch 'master' cannot be created from it -> [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.

changing clone options fixed the problem:

clone:
    depth: full

it can by add on step or whole pipeline level https://support.atlassian.com/bitbucket-cloud/docs/git-clone-behavior/.