jenkinsfile-runner
jenkinsfile-runner copied to clipboard
Document ways to include shared libraries when running jenkinsfile-runner
Just curious if there is anyway to load shared-libraries when jenkinsfile-runner invokes the pipeline. I read the comment below from (#23) from a year go, wondering if not currently supported would it be in the roadmap?
jenkinsfile-runner
in it's current design only can run a Jenkinsfile that can execute on a green field jenkins installation without any specific setup. So tons of use cases won't be supported, like using tool installations, credentials, variables, plugins with specific configuration, and ... shared libraries.For those, we need jenkinsfile-runner to include some jenkins configuration, and I indeed would like to get JCasC used for this purpose.
I cannot provide any roadmap for this feature (see https://github.com/jenkinsci/custom-war-packager/issues/124), but there are already some solutions.
Te easiest way is to use FileSystem SCM plugin and to include Pipeline libraries into the Docker image or to put them in the Filesystem. E.g. see https://github.com/jenkinsci/ci.jenkins.io-runner/blob/a05e19554af6ff36632721d638e16274f4c16790/init_scripts/src/main/groovy/PipelineLibrary.groovy
Also, Configuration-as-Code plugin can be used to define Pipeline libraries. Quick example from https://github.com/cloudbees-oss/cjd-jcasc-demo
unclassified:
globalLibraries:
libraries:
- defaultVersion: "1.2.3"
name: "Test Git Lib"
retriever:
legacySCM:
scm:
git:
branches:
- name: "*/myprodbranch"
browser:
assemblaWeb:
repoUrl: "assembla.example.com"
buildChooser: "default"
doGenerateSubmoduleConfigurations: false
extensions:
- "cleanCheckout"
- "gitLFSPull"
- checkoutOption:
timeout: 60
- userIdentity:
email: "[email protected]"
name: "custom user"
- preBuildMerge:
options:
mergeRemote: "myrepo"
mergeStrategy: RECURSIVE
mergeTarget: "master"
gitTool: "Default"
submoduleCfg:
- submoduleName: "submodule-1"
branches:
- "mybranch-1"
- "mybranch-2"
- submoduleName: "submodule-2"
branches:
- "mybranch-3"
- "mybranch-4"
userRemoteConfigs:
- credentialsId: "exampleuser-creds-id"
url: "https://git.example.com/testgitlib.git"
It would be great if somebody creates a new Documentation page for Pipeline Libraries and rewrites my comment as a documentation entry
im gonna be testing the casc shared lib setup , if the documentation is not there yet ill give it a go
@bechampion : did you get anywhere with this ? if so, could you share the setup ? I'm interested and going to start on this ..