jenkins - 从文件中获取作业 DSL 脚本时。如何在 jenkins helm chart jcasc 部分以及格式中完成此操作?
问题描述
到目前为止我的理解: 这是有道理的,我传入一个文件而不是硬编码脚本值
jobs:
- script: >
multibranchPipelineJob('configuration-as-code') {
branchSources {
git {
id = 'configuration-as-code'
remote('https://github.com/jenkinsci/configuration-as-code-plugin.git')
}
}
}
jobs:
- file: ./jobdsl/job.groovy
当前设置:在 jcasc 部分下的 jenkins helm values 文件中,我有以下内容。这很好,它与我未在此处显示的其他配置一起使用(与此讨论无关)
JCasC:
defaultConfig: true
configScripts:
pipeline-job: |
jobs:
- script: >
multibranchPipelineJob('testrepo') {
branchSources {
git {
id('testrepo')
credentialsId('bitbucketv1')
remote('https://bitbucket.org/repo/test.git')
includes("master develop")
excludes("")
}
}
问题:
如何获取我的代码并将其作为文件传递,例如“-file: ./jobdsl/job.groovy”。我在我的 jenkins helm 文件夹中创建了一个名为 jobdsl 的文件夹,并在开始时添加了带有 multibranchpipelinejob 代码片段的 job.groovy。但是我收到一条错误消息,说文件不存在。
我是否需要先创建一个配置映射并将此文件加载到 jenkins 中?或者有没有办法将文件从本地传递到上面我的掌舵图表片段中的 jcasc 脚本?另外,job.groovy 的正确格式是什么?它包括 -script: > 部分还是仅来自 multibranchpipelinejob 和向下?
解决方案
推荐阅读
- java - 将多个对象作为服务结果的最佳方法
- typescript - fp-ts 在管道中间使用异步函数
- mongodb - Mongodb排序问题
- rstudio - 具有数值和分类变量的 DBSCAN 聚类
- mysql - 如何使用 sql 从此表中获取总约会持续时间
- javascript - 如何在 CKEditor 文件上传 url 中发送 api 令牌?
- ios - 如何在 Objective-C 中从 NSOutputStream 获取图像
- python - 如何在 Python 中获取宏弹出错误消息
- javascript - 如何在没有 SVG 代码的情况下将 SVG 颜色作为附加图像进行操作?
- regex - 如何在 Tcl 中使用“regsub”或“regex”从“开始”期间删除前导和尾随字符