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

jgit fails to checkout specific branch

XMLWordPrintable

      To be able to do a proper release with the maven-release plugin, we need to be running the build on a clean checkout of a branch (not a detached HEAD).

      I'm trying to do this with the "Additional Behavior" "Check out to specifig local branch" (see screenshot).

      But when using jgit, I get this exception:

       
      Started by user admin
      [EnvInject] - Loading node environment variables.
      Building on master in workspace /Users/Shared/Jenkins/Home/jobs/dummy-tester/workspace
      Fetching changes from the remote Git repository
      Merging Revision 71099115b31453ae1d17e1808d46a7b6f8782fb4 (origin/master) onto /master
      FATAL: Unknown git object /master
      hudson.plugins.git.GitException: Unknown git object /master
      	at org.jenkinsci.plugins.gitclient.JGitAPIImpl.revParse(JGitAPIImpl.java:829)
      	at hudson.plugins.git.extensions.impl.PreBuildMerge.decorateRevisionToBuild(PreBuildMerge.java:60)
      	at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:765)
      	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:832)
      	at hudson.model.AbstractProject.checkout(AbstractProject.java:1387)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
      	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
      	at hudson.model.Run.execute(Run.java:1593)
      	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:491)
      	at hudson.model.ResourceController.execute(ResourceController.java:88)
      	at hudson.model.Executor.run(Executor.java:247)
      

      When I change the "Branch name" from "master" to "origin/master", it does not fail, but it also does not checkout a branch (I used a shell step with "git branch" to check the branch I'm staying on):

       
      Building on master in workspace /Users/Shared/Jenkins/Home/jobs/dummy-tester-jgit/workspace
      Fetching changes from the remote Git repository
      Checking out Revision 71099115b31453ae1d17e1808d46a7b6f8782fb4 (origin/master)
      [workspace] $ /bin/sh -xe /var/folders/c1/m1rcv3kj7g5250lfh3frv_s800009c/T/hudson2838431825011865626.sh
      + git branch
      * (no branch)
        master
        null
        origin/master
      Parsing POMs
      [workspace] $ java -cp /Users/Shared/Jenkins/Home/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.3.jar:/Users/Shared/Jenkins/Home/tools/hudson.tasks.Maven_MavenInstallation/MVN_303/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main /Users/Shared/Jenkins/Home/tools/hudson.tasks.Maven_MavenInstallation/MVN_303 /Users/Shared/Jenkins/Home/war/WEB-INF/lib/remoting-2.28.jar /Users/Shared/Jenkins/Home/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.3.jar 49195
      Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8
      <===[JENKINS REMOTING CAPACITY]===>channel started
      

      Doing the same (Branch name: "master) with cgit, I get this output, also telling that we really stay on a branch:

       
      Building on master in workspace /Users/Shared/Jenkins/Home/jobs/dummy-tester-cgit/workspace
      Fetching changes from the remote Git repository
      Fetching upstream changes from origin
      Checking out Revision 71099115b31453ae1d17e1808d46a7b6f8782fb4 (origin/master)
      First time build. Skipping changelog.
      [workspace] $ /bin/sh -xe /var/folders/c1/m1rcv3kj7g5250lfh3frv_s800009c/T/hudson1975846668439542655.sh
      + git branch
      * master
      Parsing POMs
      

      I also tried the same with the additional behavior "Merge before build", but the result is about the same.

            kohsuke Kohsuke Kawaguchi
            domi Dominik Bartholdi
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: