Have you tried "Branch to build" as master rather than origin/master?
On Tue, Dec 29, 2015 at 8:03 AM Michael Giroux <[email protected]> wrote: > Using Jenkins 1.609.3, Git plugin 2.4.0. > > We have configured most of our jobs to allow jobs to be initiated by the > Stash Webhook to Jenkins. To allow developers to manually initiate a build > of any branch, the jobs use the Git Parameter to set a BRANCH variable. > > Using this configuration, the Git Parameter is configured to set "**" as > the default branch to build. This allows the Stash Webhook to initiate a > build of any branch. In order to allow the job to perform a maven release, > we have configured the Git SCM to checkout to local branch "master". This > all works well as long as we are not doing a maven release, or when we do a > maven release on the master branch. The strategy breaks down if the > developer attempts a maven release on another branch when the maven > release:prepare goal tries to push pom updates. Note that the maven > release plugin uses the current local branch in the push as "git push url > localBranch:localBranch" As a result, when the build is for "some_branch" > which has been checked out to local branch "master" we get an error on "git > push ... master:master" because the remote "master" is not in sync with the > local. No surprises here since the local "master" is actually > "some_branch". > > To resolve this, we have deleted the "checkout to local branch" additional > action, and added a pre-build step that does the following:' > # checkout to a local branch using the remote branch name > LOCAL_GIT_BRANCH=${GIT_BRANCH/*\//} > git rev-parse --quiet --verify ${LOCAL_GIT_BRANCH} && git branch -D > ${LOCAL_GIT_BRANCH} > git checkout -b ${LOCAL_GIT_BRANCH} ${GIT_COMMIT} > > With this in place, the build checks the code out to a local branch with > the same name as the remote branch allowing the maven release:prepare goal > to push changes to the branch that is being build. > > NOTE that we have tried to configure the "checkout to local branch" using > the property that is configured by the Git ($BRANCH) but that results in > local branch names of "origin/master", "origin/some_branch", ... This > results in release:prepare doing pushes as "git push ... > origin/some_branch:origin/some_branch" which results in a new remote branch > named "origin/some_branch" We have seen repos with branches named > "origin/master". As a result, the desired branch is not updated, and a new > branch is created. > > QUESTION/SUGGESTION/... > It would be nice to have an option in the Git plugin to "checkout to local > branch" that derives the local branch name from the remote branch name, > without having to add our pre-build step. Thus, if I select > "origin/some_branch" from the Git parameter, I could checkout to local > branch using the Git Parameter $BRANCH which would resolve to "some_branch" > sans the "origin/" prefix. > > Steps to Reproduce: > 1. configure a parameterized job with a git parameter using "BRANCH" as > the parameter name > 2. configure the Git scm additional behavour to checkout to local branch > "$BRANCH" > 3. configure job with as a maven release. > 4. perform a maven releae, selecting one of the branches from the list of > Git Parameter options. > 5. observe console output to examine the "git push" commands generated by > the release:prepare goal. > > > -- > You received this message because you are subscribed to the Google Groups > "Jenkins Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jenkinsci-users/eeeff5a0-a7c8-4252-bbec-33168968a14e%40googlegroups.com > <https://groups.google.com/d/msgid/jenkinsci-users/eeeff5a0-a7c8-4252-bbec-33168968a14e%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtFMPjcDpP0sNd0EWrzJCsrVy1h7nH%3Da6%3DVe59ZxQTLRxQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
