This shared Library attempts to workaround an issue in Jenkins where it is not possible to set at stepname for a script.
This means that if you have a bunch of scripts running, it will be hard to separate them.
This wrapper makes it possible to give a name to the step. It also supports returnStdout: true and returnStatus: true
You probably want to fork this repo, instead of using this one directly.
- Go to Jenkins: Configuration
- Go to section "Global Pipeline Libraries"
- Fill inn any name (in the example below i called it "utils")
- Version: "master"
- "modern scm"
- Source code managment: Github 1. credentials: your credentials 2. owner: ael-computas (or your fork) 3. Repo: jenkins-script-wrapper (or your fork)
- Create a pipeline job and paste in the script below.
@Library('utils') _
node(){
stage("Without wrapper") {
sh script: 'echo the invisible script', returnStdout: true
sh script: 'echo the invisible script2', returnStdout: true
sh script: 'echo the invisible script3', returnStdout: true
}
stage("With wrapper") {
wrapper.script script: 'echo the invisible script', returnStdout: true, stepName: "description #1"
wrapper.script script: 'echo the invisible script2', returnStdout: true, stepName: "description #2"
wrapper.script script: 'echo the invisible script3', returnStdout: true, stepName: "description #3"
}
}