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

Cannot load a pipeline shared library by tag with github-branch-source-plugin 2.2.3

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • None

      After upgrading the github-branch-source-plugin from 2.0.8 to 2.2.3, loading a pipeline shared library (that uses github as its source) by tag no longer works.

      Meaning, I have a Jenkinsfile that uses

      @Library('some-shared-library@0.1') _
      

      where 0.1 is a tag

      Here's the relevant build output when github-branch-source-plugin 2.2.3 is installed:
       

      21:20:45 Connecting to https://**masked**/api/v3 using *****/****** (User name and password for **masked**)
      Obtained Jenkinsfile from 2ef326e043489c46f168b98385699ecb054e946a
      Loading library some-shared-library@0.1
       > git rev-parse --is-inside-work-tree # timeout=10
      Setting origin to https://**masked**/SE/some-shared-library.git
       > git config remote.origin.url https://**masked**/SE/some-shared-library.git # timeout=10
      Fetching origin...
      Fetching upstream changes from origin
       > git --version # timeout=10
      using GIT_ASKPASS to set credentials User name and password for **masked** 
       > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*
       > git rev-parse 0.1^{commit} # timeout=10
       > git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
       > git config remote.origin.url https://**masked**/SE/some-shared-library.git # timeout=10
      Fetching without tags
      Fetching upstream changes from https://**masked**/SE/some-shared-library.git
       > git --version # timeout=10
      using GIT_ASKPASS to set credentials User name and password for **masked** 
       > git fetch --no-tags --progress https://**masked**/SE/some-shared-library.git +refs/heads/0.1:refs/remotes/origin/0.1
      ERROR: Error fetching remote repo 'origin'
      hudson.plugins.git.GitException: Failed to fetch from https://**masked**/SE/some-shared-library.git
      	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:817)
      	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1084)
      	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1115)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:113)
      	at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.doRetrieve(SCMSourceRetriever.java:108)
      	at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.retrieve(SCMSourceRetriever.java:84)
      	at org.jenkinsci.plugins.workflow.libs.LibraryAdder.retrieve(LibraryAdder.java:150)
      	at org.jenkinsci.plugins.workflow.libs.LibraryAdder.add(LibraryAdder.java:131)
      	at org.jenkinsci.plugins.workflow.libs.LibraryDecorator$1.call(LibraryDecorator.java:114)
      	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1065)
      	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
      	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
      	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
      	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
      	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
      	at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
      	at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
      	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:129)
      	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:123)
      	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:516)
      	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:479)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:268)
      	at hudson.model.ResourceController.execute(ResourceController.java:97)
      	at hudson.model.Executor.run(Executor.java:415)
      Caused by: hudson.plugins.git.GitException: Command "git fetch --no-tags --progress https://**masked**/SE/some-shared-library.git +refs/heads/0.1:refs/remotes/origin/0.1" returned status code 128:
      stdout: 
      stderr: fatal: Couldn't find remote ref refs/heads/0.1
      Unexpected end of command stream
      
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1924)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1643)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:352)
      	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:815)
      	... 23 more
      ERROR: Error fetching remote repo 'origin'
      

      For comparison, here is the build output after I downgraded github-branch-source-plugin back to 2.0.8:

      21:23:16 Connecting to https://**masked**/api/v3 using **masked**/****** (User name and password for **masked**)
      Obtained Jenkinsfile from 2ef326e043489c46f168b98385699ecb054e946a
      Loading library some-shared-library@0.1
       > git rev-parse --is-inside-work-tree # timeout=10
      Setting origin to https://**masked**/SE/some-shared-library.git
       > git config remote.origin.url https://**masked**/SE/some-shared-library.git # timeout=10
      Fetching origin...
      Fetching upstream changes from origin
       > git --version # timeout=10
      using GIT_ASKPASS to set credentials User name and password for **masked** 
       > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*
       > git rev-parse 0.1^{commit} # timeout=10
       > git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
       > git config remote.origin.url https://**masked**/SE/some-shared-library.git # timeout=10
      Fetching without tags
      Fetching upstream changes from https://**masked**/SE/some-shared-library.git
       > git --version # timeout=10
      using GIT_ASKPASS to set credentials User name and password for **masked** 
       > git fetch --no-tags --progress https://**masked**/SE/some-shared-library.git +refs/heads/*:refs/remotes/origin/* +refs/pull/*/head:refs/remotes/origin/pr/*
      Checking out Revision 367c19fffbe5cb27ae5b23946db20483fe70532b (0.1)
      Commit message: "improve docs"
       > git config core.sparsecheckout # timeout=10
       > git checkout -f 367c19fffbe5cb27ae5b23946db20483fe70532b
       > git rev-list 367c19fffbe5cb27ae5b23946db20483fe70532b # timeout=10
      

      The main difference being that this command (using 2.0.8):

       > git fetch --no-tags --progress https://**masked**/SE/some-shared-library.git +refs/heads/*:refs/remotes/origin/* +refs/pull/*/head:refs/remotes/origin/pr/*
      

      changed to this command (using 2.2.3):

       > git fetch --no-tags --progress https://**masked**/SE/some-shared-library.git +refs/heads/0.1:refs/remotes/origin/0.1
      

      Notice the change in the ref specs
        
      Downgrading the github-branch-source back to 2.0.8 corrects the issue.

            Unassigned Unassigned
            philster_jenkins Phil Clay
            Votes:
            5 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: