机器人 救救瓜
Toggle navigation
Home
SCM-tool
Linux
Jenkins
SVN
other
About Me
Archives
Tags
jenkins 构建脚本标记为failure
? jenkins ?
2019-01-11 16:19:24
3224
0
0
gua_l
? jenkins ?
##### 报错信息 Build step 'Execute shell' marked build as failure --------- ##### 过程分析 1.笔者遇到的问题是Execute shell最后是一个脚本成功执行并正常退出,最后仍显示为failure。 2.Execute shell的failure 是当整个构建过程返回非0时,标记为失败 。所以failure 的原因,除了过程中断非0退出导致,还可能是正常执行结束后,刚好最后一个返回值是非0。 ``` Runs a shell script (defaults to sh, but this is configurable) for building the project. The script will be run with the workspace as the current directory. Type in the contents of your shell script. If your shell script has no header line like #!/bin/sh —, then the shell configured system-wide will be used, but you can also use the header line to write script in another language (like #!/bin/perl) or control the options that shell uses. By default, the shell will be invoked with the "-ex" option. So all of the commands are printed before being executed, and the build is considered a failure if any of the commands exits with a non-zero exit code. Again, add the #!/bin/... line to change this behavior. As a best practice, try not to put a long shell script in here. Instead, consider adding the shell script in SCM and simply call that shell script from Jenkins (via bash -ex myscript.sh or something like that), so that you can track changes in your shell script. ``` --------- ##### 可能的原因 最后调用的脚本的最后一个命令,虽然正常执行,但是其命令本身的返回值可能不为0,而且并没有打印在控制台 --------- ##### debug 在结尾处再加上一句 cat file 或 echo $AA 如果报错消失。则问题就是出在原来的最后一个命令。 --------- ##### 确定问题 本人遇到的报错情况是一句Accurev diff 的命令: 查看此命令的callback,用echo $? ``` accurev diff casa/nfv/mk/version.mk; echo $? ``` 发现前一句命令的返回值为1。 因此这句命令不能放在最后,为避免Jenkins报错,可以最后再加一句返回值为0 的命令。 ---------
Pre:
Jenkins 插件开发
Next:
Window Jenkins 搭建
0
likes
3224
Weibo
Wechat
Tencent Weibo
QQ Zone
RenRen
Submit
Sign in
to leave a comment.
No Leanote account?
Sign up now.
0
comments
More...
Table of content
No Leanote account? Sign up now.