I am trying to concatenate a file name by appending strings and the build number within the steps script in my Jenkinsfile and then pass it to create a zipFile, but the environment build number does not get recognized in the concatenated string. What is the correct syntax?
stage ('Publish Reports') {
steps {
script {
def fileName = "reportFiles/" + '${env.BUILD_NUMBER}' + ".zip"
zip zipFile: fileName, archive: false, dir: 'target/site/main'
}
}
}
With this syntax, the fileName gets saved as:
reportFiles/${env.BUILD_NUMBER}.zip,
instead of the actual build number, for example :
reportFiles/1.zip