jenkins - 在 Slave 上的 Pipeline 中运行 Groovy 脚本
问题描述
我目前正在尝试使用 Jenkins Pipeline 运行 Groovy 代码,但我发现我的脚本在 Master 而不是 Slaves 上运行代码的 Groovy 部分,尽管我注意到了代理。
我在 Git 中有一个名为 JenkinsFiles 的存储库,其中包含以下 JenkinsFile,以及一个名为 CommonLibrary 的存储库,其中包含在阶段中运行的代码。
这是我的 JenkinsFile :
@Library(['CommonLibrary']) _
pipeline {
agent { label 'Slave' }
stages {
stage("Preparation") {
agent { label 'Slave && Windows' }
steps {
Preparation()
}
}
}
}
这是 Preparation.groovy 文件:
def call() {
println("Running on : " + InetAddress.localHost.canonicalHostName)
}
不幸的是,当我在 Jenkins 中运行流水线时,我似乎总是让 Master 返回。我已经尝试在 Slave 上手动安装 Groovy,并且还删除了 Master 上的 Executors。任何运行的 Powershell 都会在从站上正确触发,并且 $NODE_NAME 值作为从站返回,但似乎只是在主站上运行的 Groovy 命令。
任何帮助将不胜感激。谢谢!- 托尔
解决方案
推荐阅读
- javascript - 在 ReactJs 中动态更新数组列表时出错
- mysql - Laravel 在查询生成器上的位置与连接计数
- python - 如果 dtype 是类别,则 pivot_table 需要更多内存 (MemoryError)
- javascript - 带有 AmChart 的 jquery 滑块
- javascript - 如何在 AngularJS 应用程序中访问 Shibboleth SP 属性
- vba - 使用 VBA 更改 Excel 表单标签长度以匹配其文本的长度
- c# - 表集的 UpdateAll 失败
- python - 使用 L2 正则化优化稀疏 softmax 交叉熵
- java - Spring JPA 问题 AWS Ec2 和 RDS
- javascript - javascript cookie 的过期日期不起作用 - 已更新