I have 100 of Jenkins jobs. I have to write function to skip a stage in every Jenkins job via pipeline. without editing every Jenkins job pipeline, is there any way to apply it to all jobs by single attempt?
(I am following scripted pipeline approach)
here is pipeline script I have to apply for all jobs
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
node('master')
{
stage('check the branch') {
if ( "${Branch}" == "master" || "${Branch}" == "development" ) {
echo """ $Branch branch is executed"""
}
else {
echo """$Branch branch is skipped"""
//unstable (message: "${STAGE_NAME} is unstable")
Utils.markStageSkippedForConditional(STAGE_NAME)
}
}
}