Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sergioalberto/pipeline-library
This is a Jenkins library example
https://github.com/sergioalberto/pipeline-library
Last synced: about 18 hours ago
JSON representation
This is a Jenkins library example
- Host: GitHub
- URL: https://github.com/sergioalberto/pipeline-library
- Owner: sergioalberto
- License: apache-2.0
- Created: 2022-02-28T15:20:58.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-02-28T16:23:19.000Z (over 2 years ago)
- Last Synced: 2023-08-03T17:05:48.634Z (over 1 year ago)
- Language: Groovy
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pipeline-library
Demonstrates how to use a Shared Library in Jenkins pipelines. This repository defines a single function, `sayHello`, which will echo a greeting.
## Setup instructions
1. In Jenkins, go to Manage Jenkins → Configure System. Under _Global Pipeline Libraries_, add a library with the following settings:
- Name: `pipeline-library`
- 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/sergioalberto/pipeline-library.git`
- Credentials: (leave blank)2. Then create a Jenkins job with the following pipeline (note that the underscore `_` is not a typo):
```
@Library('pipeline-library')_
stage('Demo') {
echo 'Hello World'
sayHello 'Dave'
}
```This will output the following from the build:
```
[Pipeline] stage
[Pipeline] { (Demo)
[Pipeline] echo
Hello world
[Pipeline] echo
Hello, Dave.
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
Finished: SUCCESS
```3. If you want to test another version from another branch of the library, just add `@` and the `branch name`, for example:
```
@Library('pipeline-library@another-branch')_
import com.sergiogq.GlobalVarsstage('Demo') {
echo 'Hello World'
sayHello 'Dave'
println GlobalVars.foo
}
``````
@Library('my-shared-library@master') _
/* Using a version specifier, such as branch, tag, etc */
@Library('[email protected]') _
/* Accessing multiple libraries with one statement */
@Library(['my-shared-library', 'otherlib@abc1234']) _
```### Resources
- https://www.jenkins.io/doc/book/pipeline/shared-libraries/#legacy-scm