如何在Jenkinsfile中使用jenkins版本号插件? [英] How to use jenkins version number plugin in Jenkinsfile?

查看:598
本文介绍了如何在Jenkinsfile中使用jenkins版本号插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在安装了版本号插件"的Jenkinsfile中尝试此步骤:

Trying this step in Jenkinsfile with "version number plugin" installed:

    stage("Build") {
        echo "Building..."
        TAG = ${BUILD_DATE_FORMATTED, "yyyyMMdd"}-develop-${BUILDS_TODAY}
        sh "docker build -t $IMAGE:$TAG ."
    }

并收到此错误:

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

在Jenkinsfile中使用此插件的正确方法是什么?

What is correct way to use this plugin in Jenkinsfile?

推荐答案

您需要使用它作为一个步骤.

You need to use it as a step.

tag = VersionNumber (versionNumberString: '${BUILD_DATE_FORMATTED, "yyyyMMdd"}-develop-${BUILDS_TODAY}')

看看 https://your_jenkins_url.com/pipeline-syntax/并检查剪切生成器中VersionNumber步骤的所有选项.

Take a look at https://your_jenkins_url.com/pipeline-syntax/ and check all the options for the VersionNumber step in the snipped generator.

这篇关于如何在Jenkinsfile中使用jenkins版本号插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆