[!TIP] references:
usage
load implicitly
@Library( 'library-name' ) _
@Library( 'library-name@library-version' ) _
// or load multiple
@Library([ 'library-name', 'library-name' ]) _
load dynamically
library identifier: 'library-name@library-version',
retriever: modernSCM([
$class : 'GitSCMSource',
remote : 'library-git-url',
credentialsId : 'git-credentials'
])
gerrit refspecs
references:
- * Dependencies and Class Loading
- * GERRIT_REFSPEC not recognized during scm git checkout - Jenkinsfile declarative
- How to dynamically add all methods of a class into another class
- Verifying Gerrit CRs to Your Jenkins’ Pipeline’s Shared Libraries
- git plugin 3.6.4 regression with shared libraries
- Cannot load a pipeline shared library from Bitbucket PR with cloudbees-bitbucket-branch-source 2.2.7
- multibranch: Add refspecs trait to bitbucket scm
- Import library from specific branch via variable in Jenkinsfile
- Private Jenkins Shared Libraries
- Pipeline: Shared Groovy Libraries
- something else:
refs/changes
- mandatory:
+refs/heads/*:refs/remotes/@{remote}/*
+refs/changes/*:refs/changes/*
- optional:
+refs/changes/*:refs/remotes/@{remote}/*
- mandatory:
pull-request
+refs/pull-requests/*/from:refs/remotes/@{remote}/pr/*
+refs/pull/*:refs/remotes/@{remote}/pr/*
+refs/heads/*:refs/remotes/@{remote}/*
gerrit
library (
identifier : "mylibs@" + GERRIT_REFSPEC,
retriever : modernSCM (
gerrit( traits: [[
$class: 'RefSpecsSCMSourceTrait',
templates: [
[ value: '+refs/heads/*:refs/remotes/@{remote}/*' ] ,
[ value: '+refs/changes/*:refs/changes/*' ] ,
[ value: '+refs/changes/*:refs/remotes/@{remote}/*' ]
]
]],
credentialsId: 'SSH_CREDENTIAL',
remote: 'ssh://account@gerrit.sample.com:29418/jenkins/libs'
)
)
) _
git
library (
identifier : 'devops-libs',
retriever : modernSCM ([
$class : 'GitSCMSource',
credentialsId : 'SSH_CREDENTIAL',
remote : 'ssh://account@gerrit.sample.com:29418/jenkins/libs',
traits : [
gitBranchDiscovery(),
[
$class : 'RefSpecsSCMSourceTrait',
templates : [
[ value : '+refs/heads/*:refs/remotes/@{remote}/*' ] ,
[ value : '+refs/changes/*:refs/remotes/@{remote}/*' ] ,
[ value : '+refs/changes/*:refs/changes/*' ]
]
]
]
])
)