5

jenkins中execute shell的注意事项

 7 months ago
source link: https://bajie.dev/posts/20240119-jenkins_shell/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Jenkins中execute Shell的注意事项

2024-01-19 1 分钟阅读

缺省jenkins的execute shell的方式是如下带着参数的:

sh -xe hudsonxxx.sh  

说明一下:

-e 打开开关 表示一旦脚本中有命令的返回值为非0,则脚本立即退出,后续命令不再执行;
+e 关上开关

-x 打开开关 表示执行指令后,会先显示该指令及所下的参数。
+x 关上开关

详细解释一下:

set -e 表示一旦脚本中有命令的返回值为非0,则脚本立即退出,后续命令不再执行;

set -x 表示执行指令后,会先显示该指令及所下的参数。 

set -o pipefail  表示在管道连接的命令序列中,只要有任何一个命令返回非0值,则整个管道返回非0值,即使最后一个命令返回0.  

注意在引用nvm以及meteor的环境中,要设置set +e 否则source nvm.sh的过程容易出错!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK