Reputation: 221
I'm trying to set a couple of environment variables in a Jenkinsfile, but my lack of Java/Groovy-ness seems to be failing me...
pipeline {
agent any
environment {
TMPDIR = /mnt/storage/build
TOX_DIR = $TMPDIR/$BUILD_TAG
}
...
Generates the following error on the console...
WorkflowScript: 7: Environment variable values can only be joined together with +s. @ line 7, column 26.
TOX_DIR = $TMPDIR/$BUILD_TAG
Other variations such as ...
TOX_DIR = "$TMPDIR" + "/" + "$BUILD_TAG"
or
TOX_DIR = "$TMPDIR/$BUILD_TAG"
or
TOX_DIR = "${TMPDIR}/${BUILD_TAG}"
only make matters worse.
What am I missng? Thanks....
Upvotes: 18
Views: 17387
Reputation: 14527
Solution: Error Environment variable values can only be joined together with ‘+’s
means that you missed quotes. just wrap quotes on string or string builder.
environment {
SOME_VAR = "Content"
}
Upvotes: 0
Reputation: 311
Using Jenkins v2.89.2 - Instead of using single quotes, double quotes worked for me.
environment{
MESSAGE = "release-staging-${BUILD_TIMESTAMP}"
}
Upvotes: 23
Reputation: 221
nm... answer is saner than I thought, just missing quotes...
....
environment {
TMPDIR = '/mnt/storage/work'
TOX_DIR = '${TMPDIR}/${BUILD_TAG}'
}
...
Upvotes: 2