[英]How to use jenkins version number plugin in Jenkinsfile?
Trying this step in Jenkinsfile with "version number plugin" installed:在安装了“版本号插件”的 Jenkinsfile 中尝试此步骤:
stage("Build") {
echo "Building..."
TAG = ${BUILD_DATE_FORMATTED, "yyyyMMdd"}-develop-${BUILDS_TODAY}
sh "docker build -t $IMAGE:$TAG ."
}
And getting this error:并收到此错误:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 15: unexpected token: BUILD_DATE_FORMATTED @ line 15, column 15.
TAG=${BUILD_DATE_FORMATTED, "yyyy-MM-dd"}-develop-${BUILDS_TODAY}
^
1 error
What is correct way to use this plugin in Jenkinsfile?在 Jenkinsfile 中使用这个插件的正确方法是什么?
You need to use it as a step.您需要将其用作步骤。
tag = VersionNumber (versionNumberString: '${BUILD_DATE_FORMATTED, "yyyyMMdd"}-develop-${BUILDS_TODAY}')
Take a look at https://your_jenkins_url.com/pipeline-syntax/ and check all the options for the VersionNumber step in the snipped generator.查看https://your_jenkins_url.com/pipeline-syntax/并检查剪切生成器中 VersionNumber 步骤的所有选项。
in Jenkinsfile.. try this在 Jenkinsfile.. 试试这个
env.BN = VersionNumber([
versionNumberString :'${BUILD_MONTH}.${BUILDS_TODAY}.${BUILD_NUMBER}',
projectStartDate : '2017-02-09',
versionPrefix : 'v1.'
])
In stage use the script block to run for version numbering在阶段使用脚本块运行版本编号
stage("Build") {
script {
TAG = VersionNumber(versionNumberString: '${BUILD_DATE_FORMATTED, "yyyyMMdd"}-develop-${BUILDS_TODAY}')
echo "Building..."
sh "docker build -t $IMAGE:$TAG ."
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.