-
Bug
-
Resolution: Cannot Reproduce
-
Major
-
os: rhel 6.6.0, 7.1, 7.3
jenkins: 2.164.3
Pipeline: Shared Groovy Libraries: 2.14, 2.15
Git plugin: 3.11.0, 3.12.0
Git client plugin: 2.7.7, 2.8.0
Loading a shared library at a tag does not use the provided credentials:
lib = library( identifier: "mylib@tag", retriever: modernSCM( [$class: 'GitSCMSource', remote: "GITLAB_URL/mylib.git", credentialsId: 'MY_SSH_KEY'] ) )
When using a branch name as version (identifier: "mylib@branch_name"), the library is well loaded:
Attempting to resolve branch_name from remote references...
> git --version # timeout=10
using GIT_SSH to set credentials Cle SSH pour la connexion au gitlab
> git ls-remote git@gitlab/mylib.git # timeout=10
Found match: refs/heads/branch_name revision 1dd58015a5a5b9cb4a44404871b81cce6e5e18bb
using credential MY_SSH_KEY
Cloning the remote Git repository
Cloning with configured refspecs honoured and without tags
Cloning repository git@gitlab/mylib.git
> git init /jenkins/workspace@libs/mylib # timeout=10
Fetching upstream changes from git@gitlab/mylib.git
> git --version # timeout=10
using GIT_SSH to set credentials Cle SSH pour la connexion au gitlab
> git fetch --no-tags --progress git@gitlab/mylib.git +refs/heads/*:refs/remotes/origin/*
> git config remote.origin.url git@gitlab/mylib.git # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> git config remote.origin.url git@gitlab/mylib.git # timeout=10
Fetching without tags
Fetching upstream changes from git@gitlab/mylib.git
using GIT_SSH to set credentials Cle SSH pour la connexion au gitlab
> git fetch --no-tags --progress git@gitlab/mylib.git +refs/heads/*:refs/remotes/origin/*
Checking out Revision 1dd58015a5a5b9cb4a44404871b81cce6e5e18bb (branch_name)
> git config core.sparsecheckout # timeout=10
> git checkout -f 1dd58015a5a5b9cb4a44404871b81cce6e5e18bb
Commit message: "message"
> git rev-list --no-walk 1dd58015a5a5b9cb4a44404871b81cce6e5e18bb # timeout=10
But when using a tag, a permission denied occured:
Loading library mylib@tag Attempting to resolve tag from remote references... > git --version # timeout=10 using GIT_SSH to set credentials Cle SSH pour la connexion au gitlab > git ls-remote git@gitlab/mylib.git.git # timeout=10 Found match: refs/tags/tag revision 1dd58015a5a5b9cb4a44404871b81cce6e5e18bb Resolving tag commit... (remote references may be a lightweight tag or an annotated tag) > git rev-parse --is-inside-work-tree # timeout=10 Setting origin to git@gitlab/mylib.git.git > git config remote.origin.url git@gitlab/mylib.git.git # timeout=10 Fetching origin... Fetching upstream changes from origin > git --version # timeout=10 > git config --get remote.origin.url # timeout=10 > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/* ERROR: Checkout failed hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: Permission denied, please try again. Permission denied, please try again. Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). fatal: Could not read from remote repository.
The credentials MY_SSH_KEY seems to not be used in this case.
- relates to
-
JENKINS-64803 Shared Library using folder-scoped credential fails to authenticate when using tags
-
- Closed
-
I can't duplicate the problem you're describing. I've used the `@Liibrary` syntax to load a library by tag at Jenkinsfile compile time and I've used the `lib = library(...)` syntax to load the library by tag at runtime. Both cases work to load the library by tag. I've used that syntax with modern SCM through git (as you did in your example), modern SCM through GitHub, and legacy SCM through git.
However, I suspect that the issue may be already described in the log file. The log file says:
If it is cloning the shared library repository without tags, you may need to adjust the library loading to include tags in the library.
Have you tried a syntax like:
That syntax came from the "Pipeline Syntax" helper.
Can you provide a job definition that will allow me to duplicate the problem?