Learning Resources for DevOps, SRE, Cloud & Engineering Management
Demonstrates how to use a Shared Library in Jenkins pipelines. This repository defines a single function, sayHello
, which will echo a greeting.
You can find a detailed post here - (https://www.binpipe.org/2019/09/jenkins-common-pipeline-library.html)
-
In Jenkins, go to Manage Jenkins → Configure System. Under Global Pipeline Libraries, add a library with the following settings:
- Name:
jenkins-multibranch-pipeline-library-demo
- Default version: Specify a Git reference (branch or commit SHA), e.g.
master
- Retrieval method: Modern SCM
- Select the Git type
- Project repository:
https://github.com/prasanjit-/jenkins-multibranch-pipeline-library-demo.git
- Credentials: (leave blank)
- Name:
-
Then create a Jenkins job with the following pipeline (note that the underscore
_
is not a typo):@Library('jenkins-multibranch-pipeline-library-demo')_ stage('Demo') { echo 'Hello World' sayHello 'Tux' }
This will output the following from the build:
[Pipeline] stage
[Pipeline] { (Demo)
[Pipeline] echo
Hello world
[Pipeline] echo
Hello, Tux.
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
Finished: SUCCESS
BINPIPE aims to simplify learning for those who are looking to make a foothold in the industry. Write to me at nixgurus@gmail.com if you are looking for tailor-made training sessions. For self-study resources look around in this repository, the Binpipe Blog and Youtube Channel.
📒 Maintainer: Prasanjit Singh | www.binpipe.org