node('host.domain.com') {
env.ARTIFACTORY_SERVER = 'https://host.domain.com/artifactory' env.ABC_VAR = 'abc'
env.PYPI_REPO = 'something'try {
// clean first so we have the RPMs at the end to look at / test with
stage('Cleanup') {
cleanWs()
}
stage('test vars') {
echo env.PYPI_REPO
echo params.pypi_repo1
sh 'echo PYPI_REPO without curly braces is $PYPI_REPO'
sh 'echo PYPI_REPO with curly braces is ${PYPI_REPO}'
sh "echo PYPI_REPO with double quotes is $PYPI_REPO"
sh 'echo ABC_VAR without curly braces is $ABC_VAR'
sh 'echo sleeping 5 && sleep 5s'
}
}
catch (err) {
currentBuild.result = "FAILURE"throw err
}
}
Results in:
[Pipeline] { (test vars) (hide)
[Pipeline] echo
something
[Pipeline] echo
uda-pypi-dev
[Pipeline] sh
+ echo PYPI_REPO without curly braces is something
PYPI_REPO without curly braces is something
[Pipeline] sh
+ echo PYPI_REPO with curly braces is something
PYPI_REPO with curly braces is something
[Pipeline] sh
+ echo PYPI_REPO with double quotes is something
PYPI_REPO with double quotes is something
[Pipeline] sh
+ echo ABC_VAR without curly braces is abc
ABC_VAR without curly braces is abc
[Pipeline] sh
+ echo sleeping 5
sleeping 5
+ sleep 5s
Changing the named parameter pypi_repo1 to pypi_repo yields:
[Pipeline] { (test vars)
[Pipeline] echo
something
[Pipeline] echo
uda-pypi-dev
[Pipeline] sh
+ echo PYPI_REPO without curly braces is
PYPI_REPO without curly braces is
[Pipeline] sh
+ echo PYPI_REPO with curly braces is
PYPI_REPO with curly braces is
[Pipeline] sh
+ echo PYPI_REPO with double quotes is something
PYPI_REPO with double quotes is something
[Pipeline] sh
+ echo ABC_VAR without curly braces is abc
ABC_VAR without curly braces is abc
[Pipeline] sh
+ echo sleeping 5
sleeping 5
+ sleep 5s
try { // clean first so we have the RPMs at the end to look at / test with stage('Cleanup') { cleanWs() } stage('test vars') { echo env.PYPI_REPO echo params.pypi_repo1 sh 'echo PYPI_REPO without curly braces is $PYPI_REPO' sh 'echo PYPI_REPO with curly braces is ${PYPI_REPO}' sh "echo PYPI_REPO with double quotes is $PYPI_REPO" sh 'echo ABC_VAR without curly braces is $ABC_VAR' sh 'echo sleeping 5 && sleep 5s' } } catch (err) { currentBuild.result = "FAILURE" throw err } }
{code}
Results in: {code}
[Pipeline] { (test vars) (hide) [Pipeline] echo something [Pipeline] echo uda-pypi-dev [Pipeline] sh + echo PYPI_REPO without curly braces is something PYPI_REPO without curly braces is something [Pipeline] sh + echo PYPI_REPO with curly braces is something PYPI_REPO with curly braces is something [Pipeline] sh + echo PYPI_REPO with double quotes is something PYPI_REPO with double quotes is something [Pipeline] sh + echo ABC_VAR without curly braces is abc ABC_VAR without curly braces is abc [Pipeline] sh + echo sleeping 5 sleeping 5 + sleep 5s
{code}
Changing the named parameter pypi_repo1 to pypi_repo yields:
{code}
[Pipeline] { (test vars) [Pipeline] echo something [Pipeline] echo uda-pypi-dev [Pipeline] sh + echo PYPI_REPO without curly braces is PYPI_REPO without curly braces is [Pipeline] sh + echo PYPI_REPO with curly braces is PYPI_REPO with curly braces is [Pipeline] sh + echo PYPI_REPO with double quotes is something PYPI_REPO with double quotes is something [Pipeline] sh + echo ABC_VAR without curly braces is abc ABC_VAR without curly braces is abc [Pipeline] sh + echo sleeping 5 sleeping 5 + sleep 5s