Jenkins Git plugin detached HEAD

后端 未结 9 2050
没有蜡笔的小新
没有蜡笔的小新 2020-12-02 09:55

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

相关标签:
9条回答
  • 2020-12-02 10:21

    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 BehavioursCheck out to specific local branch:

    Jenkins screenshot of setting option "Check out to specific local branch"

    Setting that value to master got me a checked out branch instead of a detached head.

    0 讨论(0)
  • 2020-12-02 10:22

    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.

    0 讨论(0)
  • 2020-12-02 10:29

    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

    0 讨论(0)
提交回复
热议问题