Jenkins 在 docker 中触发按需从站 [英] Jenkins trigger on-demand slaves in dockers

查看:16
本文介绍了Jenkins 在 docker 中触发按需从站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种在 Jenkins slave 中运行 Jenkins 作业/构建的方法,动态(按需)启动 docker.附加模式以进行视觉理解.我真正在寻找什么,我的流程看起来像:

I'm looking for a way to run Jenkins jobs/build inside Jenkins slaves, dynamically (on-demand) started docker. Attaching schema for visual understanding. What I'm actually looking for and my flow looks like:

1) 触发 Jenkins 作业(手动/git/gerrit)
2) Jenkins master(在 docker 中运行)启动从机 docker(并传递构建的脚本/指令)
3) 构建正在 Jenkins 从属设备上运行(如果是并行/管道,则为从属设备)
4) 结果返回给 Jenkins master
5) Jenkins slave docker 停止

1) Triggering Jenkins job (manually/git/gerrit)
2) Jenkins master (running in docker) starts slave machine docker (and pass script/instructions of the build)
3) Build is running on Jenkins slave (or slaves if parallel/pipeline)
4) Result returned to Jenkins master
5) Jenkins slave docker stops

这样可以吗?

推荐答案

  1. Docker 从镜像创建步骤,如安装 openssh、创建用户,在下面的链接中提到.从以下链接安装 docker 插件.

  1. Docker slave image creation steps like installing openssh, user creation, mentioned in the below link. Install docker plugin from the below link.

点击这里

进入jenkins全局配置,在云标题下,docker配置会在那里,输入docker host url和端口号,不需要凭据.给出一些连接超时值 &读取超时.

Go to jenkins global configuration, Under cloud headings, docker configuration will be there, enter docker host url with port number, credential not required. give some values for connection timeout & read timeout.

在 docker 模板下 - 输入我们在点号 1 中创建的 docker 映像名称.

Under docker template - Enter the docker image name which we created in the point number 1.

设置标签号(在Jenkins作业创建时给这个标签名,限制为这个slave名),

Set Label number (Give this label name during Jenkins job creation and restrict to this slave name),

选择使用选项 - >仅构建具有标签限制的作业.

Select the usage option - > only build job with label restriction.

执行人编号 ->最低 1. 选择启动方式为 ssh,输入用户凭据登录,这是我们在步骤 1 中在 docker 镜像中创建的.

No of executor -> minimum 1. Select launch method as ssh, enter the user credential to login, which we created in docker image in the step number 1.

为 docker slave 标签创建一个作业限制,运行,按需启动容器.

create a job restrict to docker slave label, run, ondemand it wil spun up container.

这篇关于Jenkins 在 docker 中触发按需从站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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