詹金斯将RPM安装作业过程中的错误失败 [英] jenkins shall fail on errors during rpm install job

查看:174
本文介绍了詹金斯将RPM安装作业过程中的错误失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个是我的测试机上执行的部署任务。其目的是测试从詹金斯新鲜构建RPM非常同一台机器上。

I have an deployment task that is executed on my test machine. The purpose is to test the freshly build rpm from jenkins on the very same machine.

因此​​,我成立了一个詹金斯部署作业执行以下外壳线条:

Therefore I set up a deploy job in jenkins that executes the following shell lines:

artifact=$(ls build/*.rpm | head -1)
sudo /usr/local/sbin/jenkins-rpm-install $artifact
rm -rf build/

要安装我做了一个小的shell脚本,詹金斯独占须藤权限转。

To install the rpm I made a small shell script that jenkins has exclusive sudo permissions for.

#!/bin/sh
#
# allows jenkins to install rpm as privileged user
#
# add the following line to /etc/sudoers:
# jenkins    ALL = NOPASSWD: /usr/local/sbin/jenkins-rpm-install
#

artifact=$1

rpm -vv --install --force $artifact

现在我有这个问题:每当RPM安装失败,詹金斯不承认错误code标志着构建是成功

Now I have the problem: Whenever the rpm install fails jenkins does not recognize the error code and marks the build as success.

有没有人有一个想法如何妥善解决这个问题?
此外,以提高这一过程的提示是欢迎的。

Does anyone have an idea how to properly solve this? Also tips to improve this process are welcome.

推荐答案

什么关于转错误的code在你的脚本检查简单,报詹金斯自己呢?

What about simply checking for rpm error's code in your script and report it to Jenkins yourself?

rpm -vv --install --force $artifact
error_code=$?
if [[ err_code > 0 ]]; then exit $?; fi

或者具有过载:

rpm -vv --install --force $artifact || exit $?

这篇关于詹金斯将RPM安装作业过程中的错误失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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