Below how my Jenkinsfile looks. I am trying to push or do sth when a branch name is the master is. But in this way I am getting null
as a branch name. Below is my entire Jenkinsfile
node () {
def app
stage('Clone repository') {
checkout scm
}
stage('Build image') {
app = docker.build("runtime-development-tools")
echo "${env.BRANCH_NAME}"
}
stage('Push image') {
if(env.BRANCH_NAME == "master"){
echo "Hello master"
// do something
}
}
}
Other links in StackOverflow, unfortunately, did not help me. My Jenkinsfile and other resources are in git repo. I have multi-branch and I want to perform a specific action if it's master branch.