Reputation: 41
I have created a PipelineJob in Jenkins UI, which calls 2 other Jenkins jobs:
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'
}
}
}
}
}
Then, I used xml-job-to-job-dsl plugin in order to get the job syntax in 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')
}
}
}
I took the above code, and tried to use in JCasC configuration (we are running Jenkins with helm chart on top of EKS), and created this values file:
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'
}
}
}
}
}'''
}
}
}
...
...
So once I'm running helm upgrade I see that Jenkins pod fails to read the JCasC jobs configuration, and this error message appears:
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'
What can be the cause for this error? I got the DSL syntax from the xml-job-to-dsl-job Jenkins plugin so I don't understand what am I missing here.
Thanks in advance,
Lior
Upvotes: 0
Views: 734
Reputation: 341
You probably figured this out by now but it looks to me like a yaml indentation issue, I believe the block starting with "pipelineJob" should be indented like so:
jobs:
- script: >
pipelineJob('DSL_Seed_Job') {
...
}
Upvotes: 0