Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-39573

local branch option does not work well together with merge before build



    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • git-plugin
    • None
    • OS: Linux amd64
      JRE: openjdk.x86_64 1.7.0 u55
      Jenkins 2.7.4
      Git Plugin 2.5.2
      no slaves


      I ran into some problems using the options "Check out to specific local branch" together with "Merge before build".
      Branches to build is set to "origin/feature/*", Merge before build parameters are "origin", "develop", "default", "--ff". Check out to specific local branch "**" or empty string. And I always have "Clean before checkout" and "Prune stale remote-tracking branches" enabled.

      One problem I found is that if the merge is not a fast forward, then the derived local branch is always "develop", also GIT_BRANCH is "origin/develop", GIT_LOCAL_BRANCH is "develop". I would always expect "origin/feature/XXX" / "feature/XXX" here. If the merge is a fast forward (so "develop" is then equal to "feature/XXX"), then the local branch and variables are as expected.
      Actually I just need a variable with the original checked-out branch for the build description plugin, "develop" does not make sense here.

      Sometimes I also had the following exception during build:

      08:45:21 Merging Revision 0d2bb1b8746b8e949d69e76125963a8eef5c2f8c (origin/feature/XXX) to origin/develop, UserMergeOptions{mergeRemote='origin', mergeTarget='develop', mergeStrategy='default', fastForwardMode='--ff'}
      08:45:21  > git rev-parse origin/develop^{commit} # timeout=10
      08:45:21  > git config core.sparsecheckout # timeout=10
      08:45:21  > git checkout -f origin/develop # timeout=10
      08:45:21  > git branch -a -v --no-abbrev # timeout=10
      08:45:21  > git checkout -b ** origin/develop
      08:45:21 FATAL: Could not checkout ** with start point origin/develop
      08:45:21 hudson.plugins.git.GitException: Could not checkout ** with start point origin/develop
      08:45:21 	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2003)
      08:45:21 	at hudson.plugins.git.extensions.impl.PreBuildMerge.decorateRevisionToBuild(PreBuildMerge.java:70)
      08:45:21 	at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:998)
      08:45:21 	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1087)
      08:45:21 	at hudson.scm.SCM.checkout(SCM.java:495)
      08:45:21 	at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
      08:45:21 	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
      08:45:21 	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
      08:45:21 	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
      08:45:21 	at hudson.model.Run.execute(Run.java:1741)
      08:45:21 	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)
      08:45:21 	at hudson.model.ResourceController.execute(ResourceController.java:98)
      08:45:21 	at hudson.model.Executor.run(Executor.java:410)
      08:45:21 Caused by: hudson.plugins.git.GitException: Command "git checkout -b ** origin/develop" returned status code 128:
      08:45:21 stdout: 
      08:45:21 stderr: fatal: '**' ist kein g├╝ltiger Branchname.
      08:45:21 	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1723)
      08:45:21 	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:63)
      08:45:21 	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:1997)
      08:45:21 	... 12 more

      Maybe there is some handling for the local branch option missing in the merge option?

      I played around with the options and could not always reproduce this. It might depend on the order of the additional behaviours in the configuration, I'm not sure. I could reproduce it with the local branch option before the merge option.


        Issue Links


            svenackermann Sven Ackermann created issue -
            svenackermann Sven Ackermann made changes -
            Field Original Value New Value
            Link This issue relates to JENKINS-33202 [ JENKINS-33202 ]
            markewaite Mark Waite made changes -
            Assignee Mark Waite [ markewaite ]


              Unassigned Unassigned
              svenackermann Sven Ackermann
              0 Vote for this issue
              1 Start watching this issue