bash Jenkins 在控制台输出页面中显示 echo 命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39617067/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 15:12:42  来源:igfitidea点击:

Jenkins displaying echo command in console output page

bashshelljenkinsconsoleecho

提问by Manigandan Thanigai Arasu

I have the below code in execute shell on Jenkins. My requirement is to display servernameparameter in each line to display in console output. I have used echo and got the server names and they are getting displayed in console.

我在 Jenkins 的执行 shell 中有以下代码。我的要求是servername在每一行中显示参数以显示在控制台输出中。我使用了 echo 并获得了服务器名称,它们显示在控制台中。

Code:
echo ${Server} PS_EXE="/cygdrive/powershell.exe"
echo ${Server} "wget user=$User pwd= $pwd http://artifactory/dev-package.zip"
echo ${Server} "sleep 20s"

All lines contain echo server to display the server names

所有行都包含 echo server 以显示服务器名称

Output:
+echo SD998.domain.com PS_EXE="/cygdrive/powershell.exe"
SD998.domain.com PS_EXE="/cygdrive/powershell.exe"
+echo SD999.domain.com "wget user=$User pwd= $pwd http://artifactory/dev-package.zip"
SD999.domain.com "wget user=$User pwd= $pwd http://artifactory/dev-package.zip"

The echo statement is getting displayed in console output and next the output is getting displayed. I need to remove the echo related statements from Console output. Please help me to achieve this.

echo 语句显示在控制台输出中,接下来显示输出。我需要从控制台输出中删除与 echo 相关的语句。请帮助我实现这一目标。

回答by Rubén Pozo

If you are executing the task in a linux slave try with:

如果您在 linux slave 中执行任务,请尝试:

#!/bin/bash
echo ${Server} PS_EXE="/cygdrive/powershell.exe"
echo ${Server} "wget user=$User pwd= $pwd http://artifactory/dev-package.zip"
echo ${Server} "sleep 20s"

If you are executing in a windows slave try executing windows command:

如果您在 windows slave 中执行,请尝试执行 windows 命令:

@echo %Server% PS_EXE="/cygdrive/powershell.exe"
@echo %Server% "wget user=%User% pwd= %pwd% http://artifactory/dev-package.zip"
@echo %Server% "sleep 20s"