I think it should work and I don't know why it isn't.
It is unusual for someone to load a shared library dynamically using the library
step instead of using the @library
annotation. Since you are specifying a retriever
, why don't you pass the tag to it?
You can find out all the options for GitSCM
by going to the snippet generator and trying the library
step.
This is what I came up with:
library changelog: false, identifier: 'jenkins-shared-library', retriever: legacySCM([$class: 'GitSCM', branches: [[name: '41']], extensions: [], userRemoteConfigs: [[credentialsId: 'account', url: 'https://website.com.repo.git']]])
but I personally like to structure my code a bit more
final Object lib = library(
[
identifier: 'jenkins-shared-library',
changelog: false,
retriever: legacySCM(
[
$class: 'GitSCM',
branches: [
[
name: '41'
]
],
extensions: [],
userRemoteConfigs: [
[
credentialsId: 'account',
url: 'https://website.com.repo.git'
]
]
]
)
]
)
I hope that specifying the tag via the GitSCM works for you.
I think you should drop by https://community.jenkins.io/ and post about what you are trying to do in your pipeline. When you load a library dynamically because you lose one of the main benefits which is that shared libraries arent subjected to script security, at least when they are loaded via the @library
annotation.