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

Shared library defined on folder cannot be specified by tag

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • Jenkins 2.289.3 on RHEL7 with OpenJDK 1.8.0_302-b08
      cloudbees-folder 6.16
      git 4.8.1
      git-client 3.9.0
      workflow-cps 2.93
      workflow-cps-global-lib 2.21

      I have a shared library defined on a folder with retrieval method 'Modern SCM' and git as scm.

      When defining a very simple pipeline using this shared lib such as:

      pipeline {
          libraries {
              lib 'folderlib@1.0'
          }
          agent any
          stages {
              stage('SayHello') {
                  steps {
                      echo 'hello'
                  }
              }
          }
      }
      

      the pipeline fails:

      Running in Durability level: PERFORMANCE_OPTIMIZED
      [Pipeline] Start of Pipeline
      [Pipeline] library
      Loading library folderlib@1.0
      Attempting to resolve 1.0 from remote references...
      > git --version # timeout=10
      > git --version # 'git version 2.27.0'
      using GIT_SSH to set credentials XXX
      [INFO] Currently running in a labeled security context
      [INFO] Currently SELinux is 'enforcing' on the host
      > /usr/bin/chcon --type=ssh_home_t /tmp/jenkins-gitclient-ssh8726016875039526690.key
      > git ls-remote -h -t – ssh://git@bitbucket.acme.org:7999/xx/folderlevel-shared-lib.git # timeout=10
      Found match: refs/tags/1.0 revision f7bbf359fb7646e7e83abb79648143f6160a5e6f
      Resolving tag commit... (remote references may be a lightweight tag or an annotated tag)
      > git rev-parse --resolve-git-dir /var/lib/jenkins/caches/git-51201b6bdeacef6d6811a749e31c35f3/.git # timeout=10
      Setting origin to ssh://git@bitbucket.acme.org:7999/xx/folderlevel-shared-lib.git
      > git config remote.origin.url ssh://git@bitbucket.acme.org:7999/xx/folderlevel-shared-lib.git # timeout=10
      Fetching origin...
      Fetching upstream changes from origin
      > git --version # timeout=10
      > git --version # 'git version 2.27.0'
      > git config --get remote.origin.url # timeout=10
      > git fetch --tags --force --progress – origin +refs/heads/*:refs/remotes/origin/* # timeout=10
      ERROR: Checkout failed
      hudson.plugins.git.GitException: Command "git fetch --tags --force --progress – origin +refs/heads/*:refs/remotes/origin/*" returned status code 128:
      stdout:
      stderr: Permission denied (publickey).
      fatal: Could not read from remote repository.

      Please make sure you have the correct access rights
      and the repository exists.

      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2681)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2102)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:86)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:624)
      at jenkins.plugins.git.AbstractGitSCMSource.doRetrieve(AbstractGitSCMSource.java:370)
      at jenkins.plugins.git.AbstractGitSCMSource.doRetrieve(AbstractGitSCMSource.java:330)
      at jenkins.plugins.git.AbstractGitSCMSource.retrieve(AbstractGitSCMSource.java:956)
      at jenkins.scm.api.SCMSource.fetch(SCMSource.java:636)
      at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.lambda$retrieve$0(SCMSourceRetriever.java:125)
      at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.retrySCMOperation(SCMSourceRetriever.java:140)
      at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.retrieve(SCMSourceRetriever.java:125)
      at org.jenkinsci.plugins.workflow.libs.LibraryAdder.retrieve(LibraryAdder.java:196)
      at org.jenkinsci.plugins.workflow.libs.LibraryStep$Execution.run(LibraryStep.java:210)
      at org.jenkinsci.plugins.workflow.libs.LibraryStep$Execution.run(LibraryStep.java:155)
      at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
      at hudson.security.ACL.impersonate2(ACL.java:449)
      at hudson.security.ACL.impersonate(ACL.java:461)
      at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
      [Pipeline] End of Pipeline
      ERROR: Maximum checkout retry attempts reached, aborting
      Finished: FAILURE

      If I define the shared lib such as

              lib 'folderlib@master'
      

      or

              lib 'folderlib@tags/1.0'
      

      it does work.

      Looking at the console output this row is strange:

      hudson.plugins.git.GitException: Command "git fetch --tags --force --progress – origin +refs/heads/*:refs/remotes/origin/*" returned status code 128:

      There is no URL specified, which probably is the issue. For some reason it is not specified when using the tag in the lib definition. The URL is defined if any of the working shared lib definitions is used.

            Unassigned Unassigned
            ahammar Anders Hammar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: