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
493 stars 181 forks source link

Cannot update paths and switch to branch 'master' #220

Closed mtshane closed 4 years ago

mtshane commented 4 years ago

Trying to get this working this morning on our maven modules, but keep running in to the same issue and not sure how to troubleshoot it.

Our projects are in bitbucket, and we're running build pipelines. I originally tried the maven-release plugin, which was able to build just fine, but didn't support our git-flow model very well (it commits the new snapshot to master, then we have to manually merge it down to develop to continue)

For some reason, both the release and realize-finish goals continue to fail with the following

`[INFO] Checking for uncommitted changes.

[INFO] Fetching remote branch 'origin develop'.

[INFO] Comparing local branch 'develop' with remote 'origin/develop'.

[INFO] Local branch 'master' doesn't exist. Trying to fetch and check it out from 'origin'.

[INFO] Fetching remote branch 'origin master'.

[INFO] Creating a new branch 'master' from 'origin/master' and checking it out.

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 4.309 s

[INFO] Finished at: 2020-03-29T16:07:09Z

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.14.0:release (default-cli) on project name-of-our-module: release: fatal: Cannot update paths and switch to branch 'master' at the same time.

[ERROR] Did you intend to checkout 'origin/master' which can not be resolved as commit?`

mtshane commented 4 years ago

I kept hammering at this trying to figure out what it was doing.. and while I'm not sure what the source of the problem is, I did find a solution. I think it may be just the way that bitbucket creates the docker for the pipeline to run in, but it had the following setting when I ran git config --list in the pipeline stage

remote.origin.fetch=+refs/heads/develop:refs/remotes/origin/develop

I inserted a reset before running the release, and that seemed to make it happy again.

- git config --replace-all remote.origin.fetch +refs/heads/*:refs/remotes/origin/* - mvn -B -s settings.xml gitflow:release-start gitflow:release-finish

aleksandr-m commented 4 years ago

So, have you resolved it?

mtshane commented 4 years ago

Yea. It wasn’t the plugins issue. It really couldn’t check out master. I just couldn’t figure out why until I started adding a bunch of echo lines to the pipeline. All I can assume is that the initial BitBucket pipeline is very specific on only allowing access to the current branch.

On Fri, Apr 3, 2020 at 3:24 PM Aleksandr Mashchenko < notifications@github.com> wrote:

So, have you resolved it?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aleksandr-m/gitflow-maven-plugin/issues/220#issuecomment-608676324, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVQOQMOXRXMCQSAZ4BDWS3RKZHX3ANCNFSM4LWA47CA .

-- Sent from mobile