jenkins在make命令失败时完成了成功

时间:2015-06-02 10:05:43

标签: java android jenkins makefile

我使用jenkins每晚构建android映像,然后发现即使makecp命令失败,jenkins仍然成功。

最后一次构建设置是将日志文件复制到作业目录,所以也许它成功了,然后jenkins完成了SUCCESS。

Text-finder插件只能设置构建不稳定而不是失败,所以如何在make失败时使构建失败。

日志是这样的:

make: \*** No rule to make target \`device/vendor/product/google_frameworks/Google_Play.apk', needed by `out/target/product/device/system/app/Google_Play.apk'.  Stop.
make: *** Waiting for unfinished jobs....
target R.java/Manifest.java: FileBrowser(out/target/common/obj/APPS/FileBrowser_intermediates/src/R.stamp)
Warning: AndroidManifest.xml already defines versionCode (in http://schemas.android.com/apk/res/android); using existing value in manifest. untranslatable but exists in locale 'zh_CN'
aapt: warning: string 'pref_development_uastring' has no default translation in packages/apps/Browser/res; found: zh_CN zh_TW
Note: Recompile with -Xlint:unchecked for details.
======================>End<=======================
cp: cannot stat `/home/jenkins/job_name/source/out/target/product/device/package.img': No such    file or directory
Extended Email Publisher is currently disabled in project settings
Finished: SUCCESS

1 个答案:

答案 0 :(得分:1)

如果脚本的最后一个命令成功,则Jenkins作业被标记为成功。

一个简单的解决方法是在bash脚本开始时指定set -e

  

-e如果命令以非零状态退出,则立即退出。

您还可以指定陷阱:trap 'exit 1' ERR,以便在发生错误时停止脚本。