A step in my pipeline uploads .tar to an artificial server. I get a "Basic replacement" error when passing to env.BUILD_NUMBER, but the same commands work when the number is hardcoded. The script is written to groovy through jenkins and runs in the jenkins workspace.
sh 'curl -v --user user:password --data-binary ${buildDir}package${env.BUILD_NUMBER}.tar -X PUT "http://artifactory.mydomain.com/artifactory/release-packages/package${env.BUILD_NUMBER}.tar"'
returns errors:
[Pipeline] sh [Package_Deploy_Pipeline] Running shell script /var/lib/jenkins/workspace/ Package_Deploy_Pipeline@tmp /durable-4c8b7958/script.sh: 2: /var/lib/jenkins/workspace/ Package_Deploy_Pipeline@tmp /durable-4c8b7958/script.sh: Bad substitution [Pipeline] } //node [Pipeline] Allocate node : End [Pipeline] End of Pipeline ERROR: script returned exit code 2
If the hard code in the build number and the swap is ${env.BUILD_NUMBER} , I get no errors and the code works successfully.
sh 'curl -v --user user:password --data-binary ${buildDir}package113.tar -X PUT "http://artifactory.mydomain.com/artifactory/release-packages/package113.tar"'
I use $ {env.BUILD_NUMBER} in other sh commands within the same script and have no problems elsewhere.
source share