Is there a way to create a post build script for all Jenkins jobs? Some script that is shared across jobs? I would like to avoid manually creating a post-build script for each job if possible.
AFAIK there is no job that will always run after any other job. You can emulate that creating a new job and then either configure a post build trigger on all your jobs to run the new one, or configure a build trigger in the new job to run after all the jobs you specify.
However, if all your jobs are pipelines and you have a shared library you can create a step that is actually a pipeline with a built-in post
, for example consider a step called postPipeline.groovy
:
def call(Closure body) {
pipeline {
agent any
stages {
stage('Run pipeline') {
steps {
script {
body()
}
}
}
}
post {
always {
<< routine post actions go here >>
}
}
}
}
By changing all the pipelines to use this step you ensure they all run the post script:
postPipeline {
stage('Pipeline stage') {
<< code >>
}
.
.
.
}
Still, in any case you get yourself involved in manual labor.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.