如果执行shell失败,请不要让jenkins构建失败 [英] don't fail jenkins build if execute shell fails

查看:469
本文介绍了如果执行shell失败,请不要让jenkins构建失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为构建过程的一部分,我正在运行git commit作为execute shell步骤.但是,如果工作空间中没有任何更改,则詹金斯(Jenkins)将使构建失败.这是因为当没有任何更改要提交时,git返回错误代码.我想中止构建,或者只是在这种情况下将其标记为不稳定.有什么想法吗?

As part of my build process, I am running a git commit as an execute shell step. However, if there are no changes in the workspace, Jenkins is failing the build. This is because git is returning an error code when there are no changes to commit. I'd like to either abort the build, or just mark it as unstable if this is the case. Any ideas?

推荐答案

我能够使用以下找到的答案来解决这个问题:

I was able to get this working using the answer found here:

如何git无错误地提交任何内容?

git diff --quiet --exit-code --cached || git commit -m 'bla'

这篇关于如果执行shell失败,请不要让jenkins构建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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