如何将Docker容器上的错误冒泡到主机中的詹金斯 [英] How to bubble up errors on docker containers to jenkins in host machine

查看:75
本文介绍了如何将Docker容器上的错误冒泡到主机中的詹金斯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道如何将Docker容器中的错误冒泡/处理到主机中的詹金斯,最好的方法是什么?

I need to know how to bubble up / handle errors on docker containers to a jenkins in the host machine, what is the best approach?

我只能使用docker来做,还是需要使用docker-compose?

I can do it only using docker or i need use docker-compose?

如果其中运行的代码失败,我如何告诉docker抛出失败的退出代码?

How I can tell to docker to throw a failed exit code if the code running inside of it fail?

示例:

我想在詹金斯中运行一个使用nodeJs运行脚本的docker镜像. 如果此脚本因退出代码1而失败,则我需要Jenkins使构建失败.

I want to run in jenkins a docker image that run a script with nodeJs. If this script fail with exit code 1 I need that Jenkins fail the build.

谢谢

推荐答案

您好,并提供了有关do​​cker和CMD命令中退出代码的信息.我能够在启动Docker容器的bash脚本中使用set -e将多个Docker容器内的所有错误抛出给jenkins. 如果任何容器的退出代码都为非零,则脚本将停止当前执行,并且退出代码将由jenkins捕获,而随后执行下一个docker容器执行.

Hi with the info about the exit codes in docker and CMD command. I was able to throw up all the errors inside of more than one docker container to jenkins using set -e in a bash script starting my docker containers. If any container fails with a non zero exit code the script stop the current execution and the exit code is catched by jenkins instead to follow with the next docker container execution.

这篇关于如何将Docker容器上的错误冒泡到主机中的詹金斯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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