Hi, I have the following Jenkinsfile pipeline:
pipeline {
options {
skipDefaultCheckout()
timestamps ()
}
agent { label 'compute-env-spotfleet' }
stage('Testing push of requirements') {
if (CURRENT_BRANCH == 'master') { <----- is this line correct?
when{ expression { return fileExists('build-scripts/pushreqs.sh') } }
steps {
requirementsPusher()
}
}
}
stage('Cleanup'){
when{ expression { return fileExists('build-scripts/cleanup.sh') } }
steps{
cleanUpScript()
}
}
I would like to add an if
statement such that the stuff in the Testing push of requirements
stage only runs on the controller branch, and not when other branches are pushed to controller!
Is there a way to reference the name of the branch in Jenkinsfile?