詹金斯掌舵图作业DSL问题



我在Jenkins UI中创建了一个PipelineJob,它调用了其他2个Jenkins作业:

pipeline {
agent any 
stages {
stage("Trigger disable script approval") {
steps {
script{
build job: 'Tools/Disable_Script_Approval'
}
}
}
stage("Trigger Jobs loading into Jenkins") {
steps {
script{
build job: 'Tools/Seed_Job_Executor'
}
}
}
}
}
然后,我使用xml-job-to-job-dsl :
pipelineJob("testLior") {
description()
keepDependencies(false)
definition {
cpsScm {
"""pipeline {
agent any 
stages {
stage("Trigger disable script approval") {
steps {
script{
build job: 'Tools/Disable_Script_Approval'
}
}
}
stage("Trigger Jobs loading into Jenkins") {
steps {
script{
build job: 'Tools/Seed_Job_Executor'
}
}
}
}
}"""        }
}
disabled(false)
configure {
it / 'properties' / 'com.sonyericsson.rebuild.RebuildSettings' {
'autoRebuild'('false')
'rebuildDisabled'('false')
}
}
}

我使用了上面的代码,并尝试在JCasC配置中使用(我们在EKS之上运行带有helm chart的Jenkins),并创建了这个值文件:

controller:
JCasC:
configScripts:
casc-jobs: |
jobs:
- script: >
pipelineJob('DSL_Seed_Job') {
definition {
cpsScm {
'''pipeline {
agent any 
stages {
stage('Trigger disable script approval') {
steps {
script{
build job: 'Tools/Disable_Script_Approval'
}
}
}
stage('Trigger Jobs loading into Jenkins') {
steps {
script{
build job: 'Tools/Seed_Job_Executor'
}
}
}
}
}'''    
}
}
}
...
...

所以一旦我运行helm upgrade我看到Jenkins pod无法读取JCasC作业配置,并且出现以下错误消息:

2021-10-21 11:04:37.178+0000 [id=22]    SEVERE  hudson.util.BootFailure#publish: Failed to initialize Jenkins
while scanning a simple key
in /var/jenkins_home/casc_configs/casc-jobs.yaml, line 3, column 3:
pipelineJob('DSL_Seed_Job') {
^
could not find expected ':'
in /var/jenkins_home/casc_configs/casc-jobs.yaml, line 12, column 38:
...                        build job: 'Tools/Disable_Script_Approval'

这个错误的原因是什么?我从xml-job-to-dsl-job中获得DSL语法Jenkins插件,所以我不明白我在这里错过了什么。

提前感谢,
Lior

你现在可能已经明白了,但它看起来像一个yaml缩进问题,我相信以"pipelineJob"应该像这样缩进:

jobs:
- script: >
pipelineJob('DSL_Seed_Job') {
...
}

相关内容

  • 没有找到相关文章

最新更新