Jenkins不在groovy管道中的ECHO请求中显示变量输出 [英] Jenkins does not show variables output in ECHO request in the groovy-pipeline

查看:446
本文介绍了Jenkins不在groovy管道中的ECHO请求中显示变量输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如.我在groovy-pipeline中有这部分代码:

just for example. I have this part of code in groovy-pipeline:

                echo "${GIT_BRANCH}"

                if ("${GIT_BRANCH}" == 'origin/mysuperbranch') {
                    echo 'Branch name is "${GIT_BRANCH}". We can continue'
                } else {
                    echo 'Branch name is "${GIT_BRANCH}". We can not continue'
                    isValid = false
                    return true
                }

让我们看一下输出:

[Pipeline] echo
origin/mysuperbranch
[Pipeline] echo
Branch name is "${GIT_BRANCH}". We can continue

为什么在第一个输出中我可以看到变量${GIT_BRANCH}中的内容,但是在下一个输出中,我只能看到${GIT_BRANCH}.你能帮我吗?

Why in first output i can see what is in the variable ${GIT_BRANCH}, but in the next output, i see only ${GIT_BRANCH}. Can you help me please ?

推荐答案

引用字符串插值,您正在将变量作为字符串写入控制台.您必须从变量中删除",并在整个命令中使用它们来识别变量.

Refering to the String Interpolation you are writing the variable as string to the console. You have to remove the " from the variable and use them on the whole command to recognize variables.

echo "Branch name is ${GIT_BRANCH}. We can not continue"

这篇关于Jenkins不在groovy管道中的ECHO请求中显示变量输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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