I am new to Git and also to Jenkins. My problem is that I can\'t get the Jenkins Maven release plugin to work.
When I build a common Maven build with Jenkins, it wor
The Checkout/merge to local branch (optional) field is gone in the current (2.2.1) version of the Git plugin.
It has moved to Additional Behaviours → Check out to specific local branch:
Setting that value to master got me a checked out branch instead of a detached head.
Add to maven command line for the release prepare: -DpushChanges=false -DlocalCheckout=true
This means maven would use what jenkins got inside working directory .git
, and neither clone the remote or push to remote.
I recommend to configure fully qualified refs/remotes/origin/develop
as your Git "Branch to build". This way it seems more understandable to me.
In such case your $GIT_BRANCH would get magically set by Jenkins to origin/develop
Then, instead of using overly complicated (but portable) GitPublisher, just add a post-build step "Execute Shell":
echo Remote branch is $GIT_BRANCH, replacing origin with refs/heads.
git push --follow-tags "$GIT_URL" "+HEAD:${GIT_BRANCH/#origin\//refs/heads/}"
This pushes whatever maven changed, like pom.xml and tags.
I want to build several branches, and check out each branch under its name. I am using GIT plugin 2.4.0.
The answer by Matthias Braun gets you a named branch, but it is not named after the remote branch.
Instead of setting the local branch master
, set the local branch $GIT_BRANCH
.
I found that solution in https://issues.jenkins-ci.org/browse/JENKINS-6856