jenkins - 在没有从站的远程主机上执行 Jenkins 管道
问题描述
我的 Jenkins 在 host1 上,我希望使用 Jenkins 管道触发 host2 上的 ansible。这可以通过在 host2 上创建一个从节点并agent
在 Jenkins 管道中指定来完成。
但是,我在 host2 上没有 Jenkins 从站。
相反,Jenkins 可以连接到 host2,通过Server Groups Center
它可以在下面找到Jenkins Global Configuration
我需要在 host2 上安装一个 Jenkins 从站吗?如果没有,那么我如何Server Groups Center
在 Jenkins 管道中使用来触发 host2 上的 Ansible?请提供示例代码...</p>
解决方案
我需要在 host2 上安装 Jenkins 从站吗?
不,如果你有 Linux host2
:你可以简单地通过 SSH 运行任何命令。
如何使用 Jenkins 管道中的服务器组中心在 host2 上触发 Ansible?
Server Groups Center
block 来自SSH2 Easy 插件,它很老,不支持Jenkins 管道。因此,您不能在管道中使用来自该设置块的信息。
但是还有其他的 SSH 插件;例如,尝试通过 SSH插件发布。该插件将Publish over SSH
块添加到Jenkins Global Configuration
,您可以在其中指定host2
连接参数。
然后您可以编写如下管道步骤(是您在块中键入{HOST2}
的名称):host2
Publish over SSH
Jenkins Global Configuration
steps {
sshPublisher \
failOnError: true, \
publishers: [ \
sshPublisherDesc( \
configName: "{HOST2}", \
transfers: [ \
sshTransfer (execCommand: "ansible -m ping all -i inventory_file", execTimeout: 120000) \
] \
) \
]
}
推荐阅读
- ios - 制作单位转换应用程序,单击文本字段时无法获取数字键盘
- python - 嵌套列表/字典理解如何添加缺少的元素
- ruby-on-rails - 参数丢失或值为空:
- date - SAS 和 Coalesce 函数插入缺失的日期值?
- python - 要求用户输入数字并将它们相乘
- python - ValueError:在乘法运算中使用占位符变量时不支持无值
- javascript - 为什么我的“Rock Paper Scissors”程序无法运行并不断崩溃我的页面?
- python - 将单行中的多个列与标题作为变量组合
- c++ - 为什么旧的空抛出规范被重写为新语法“noexcept”?
- go - Golang 错误:不能使用 (type [5]int) 作为中位数参数中的 int 类型