在Jenkins控制台输出中回显 [英] Echo off in Jenkins Console Output

查看:249
本文介绍了在Jenkins控制台输出中回显的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在遵循指南如何使用Jenkins签署Android apk.我已经用KSTOREPWD和KEYPWD参数化了Jenkins的工作. Jenkins的工作配置(Build-> Execute shell)的一部分是获取这些参数并将其存储为环境变量:

I'm following guideline how to sign Android apk with Jenkins. I have parametrized Jenkins job with KSTOREPWD and KEYPWD. A part of Jenkins' job configuration (Build->Execute shell) is to take those parameters and store them as environment variables:

export KSTOREPWD=${KSTOREPWD}
export KEYPWD=${KEYPWD}
...
./gradlew assembleRelease

问题是当构建结束时,任何人都可以访问构建控制台输出"并查看输入了什么密码;该输出的一部分:

The problem is when the build is over anybody can access the build "Console Output" and see what passwords were entered; part of that output:

08:06:57 + export KSTOREPWD=secretStorePwd
08:06:57 + KSTOREPWD=secretStorePwd
08:06:57 + export KEYPWD=secretPwd
08:06:57 + KEYPWD=secretPwd

因此,我想在export命令输出之前抑制回声,并在export命令之后重新启用回声.

So I'd like to suppress echo before output from export commands and re-enable echo after export commands.

推荐答案

默认情况下,Jenkins使用set -x启动 Execute Shell 脚本.这将导致所有命令被回显

By default, Jenkins launches Execute Shell script with set -x. This causes all commands to be echoed

您可以在任何命令之前键入set +x来临时覆盖该行为.当然,您需要set -x才能再次显示它们.

You can type set +x before any command to temporary override that behavior. Of course you will need set -x to start showing them again.

您可以通过在构建步骤的顶部放置以下内容来覆盖整个脚本的此行为:
#!/bin/bash +x

You can override this behaviour for the whole script by putting the following at the top of the build step:
#!/bin/bash +x

这篇关于在Jenkins控制台输出中回显的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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