Jenkins pipeline之将命令的运行结果赋值给变量

在使用pipeline声明式语法编写自动化cicd时,难免会遇到需要将某一个命令的执行返回结果赋值给变量的情况。

如下:

def tag = sh(script: "git describe --tags --always", returnStdout:true).trim()

TAG_NEW = tag

posted @ 2020-08-18 23:23  frantzz  阅读(3944)  评论(1编辑  收藏  举报