我正在尝试在Jenkins文件中设置几个环境变量,但我缺少Java / Groovy-ness似乎让我失望......
pipeline {
agent any
environment {
TMPDIR = /mnt/storage/build
TOX_DIR = $TMPDIR/$BUILD_TAG
}
...
在控制台上生成以下错误...
WorkflowScript: 7: Environment variable values can only be joined together with +s. @ line 7, column 26.
TOX_DIR = $TMPDIR/$BUILD_TAG
其他变体如......
TOX_DIR = "$TMPDIR" + "/" + "$BUILD_TAG"
或
TOX_DIR = "$TMPDIR/$BUILD_TAG"
或
TOX_DIR = "${TMPDIR}/${BUILD_TAG}"
只会让事情变得更糟。
我想知道什么?感谢....
答案 0 :(得分:7)
使用Jenkins v2.89.2 - 双引号不是使用单引号,而是为我工作。
environment{
MESSAGE = "release-staging-${BUILD_TIMESTAMP}"
}
答案 1 :(得分:0)
nm ...答案比我想象的要好,只是缺少引号......
....
environment {
TMPDIR = '/mnt/storage/work'
TOX_DIR = '${TMPDIR}/${BUILD_TAG}'
}
...
答案 2 :(得分:0)
解决方案:错误Environment variable values can only be joined together with ‘+’s
表示您缺少引号。只需在字符串或字符串生成器上加上引号即可。
environment {
SOME_VAR = "Content"
}