imekon
imekon

Reputation: 1523

Jenkins variable not expanding, why?

I'm setting up a stage in a Jenkins pipeline script.

I wanted to create artifacts with build numbers in the name so I setup the following command:

bat '7z a -tzip staging_${BUILD_NUMBER} @JenkinsStagingFiles.txt'
archiveArtifacts 'staging_${BUILD_NUMBER}.zip'

The bat command doesn't expand ${BUILD_NUMBER} and leaves it alone, whereas the archiveArtifacts command does. How do I get the bat command to expand ${BUILD_NUMBER}?

Upvotes: 2

Views: 2807

Answers (1)

imekon
imekon

Reputation: 1523

The answer is to use " on the bat line and ' on the archiveArtifacts line

bat "7z a -tzip staging_${BUILD_NUMBER} @JenkinsStagingFiles.txt"
archiveArtifacts 'staging_${BUILD_NUMBER}.zip'

Upvotes: 1

Related Questions