jenkins - 如何在测试工具中模拟 Jenkins 作业参数?
问题描述
我正在尝试使用测试工具来测试作业 dsl 脚本:https ://github.com/testcookbook/jenkins_harness
种子 Jenkins 作业为其配置了参数,可以在脚本中访问它们,例如“${myparam}”
我像这样在 spock 中运行种子作业:
def 'test script #file.name'(File file) {
given:
def jobManagement = new JenkinsJobManagement(System.out, [:], new File('.'))
def myparam = 'sldkjflsdkjfs'
// this also doesn't work (No such property: myparam for class: script)
jobManagement.parameters.put("myparam", 'sldfjlsdjflskdjf')
when:
new DslScriptLoader(jobManagement).runScript(file.text)
then:
noExceptionThrown()
where:
file << jobFiles // uses groovy's automatic getter => getJobFiles()
}
加载 dsl 脚本的方式不会选择“myparam”。我如何以及在哪里设置它以便我可以在本地运行它并将“myparam”设置为不同的值,然后将在实际的种子作业配置中进行配置?
解决方案
推荐阅读
- python - FastAPI 资源扩展
- reactjs - 无法在反应中访问 API
- c# - 实体框架,泛型:如何处理从共同继承类型派生的多个表?
- python - SQL 包含 0 个参数标记,但提供了 1 个参数 | pyodbc
- performance - 3 个分析跟踪代码中的哪一个将提供最佳性能(添加了有关我的网站的具体详细信息)
- angular - ngFor 不使用订阅 - Angualr
- java - 将 Spring Boot 应用程序部署到 Heroku
- flutter - Flutter Getx BottomNavigation with GetPage
- django - Restframework序列化器关系获取外键字段
- amazon-redshift - 如何使用带有格式 csv 的保存表和来自 EMR 的标题以及存储为文本文件的胶水