I am trying to execute a shell command in my jenkinsfile but the variables that i set arent showing up in the shell command I am trying to execute. here is my code:
def branchName = BRANCH_NAME
def newBranchName = branch name.split('/')[1]
pipeline {
agent any
stages {
stage ('build') {
steps {
sh 'docker build -t 771225398400.dkr.ecr.us-west-2.amazonaws.com/nics/em-api:$newBranchName .'
}
}
}
}
This outputs
docker build -t 771225398400.dkr.ecr.us-west-2.amazonaws.com/nics/em-api: .
However, When I simply run a "println($newBranchName)", the correct String is printed. Any clue as to why the variables dont appear? Any help is appreciated.
Thanks!