I have a jenkins DSL freestyleJob which polls a github repo and triggers when it detects a change.
I want to trigger a 'pipeline' job within this freestyleJob. Is this possible?
I see in the web ui that I can add a 'post-build' step to build another project, and specify my pipeline. How would I actually code this in my jenkins casc job?
I tried the following:
freeStyleJob('poll_scm_job') {
scm {
github('my-repo/test-jenkins', '*/main')
}
triggers {
scm('H/2 * * * *')
}
steps {
shell(readFileFromWorkspace('jobs/Myjob.groovy'))
}
postBuildSteps('SUCCESS') {
shell("echo 'post build step'")
}
}
However this caused the job-configurator to fail with error: ERROR: (script, line 19) No signature of method: javaposse.jobdsl.dsl.jobs.FreeStyleJob.postBuildSteps() is applicable for argument types: (java.lang.String, script$_run_closure1$_closure7) values: [SUCCESS, script$_run_closure1$_closure7@6f249809]
I also tried the following with a similar error:
freeStyleJob('poll_scm_job') {
scm {
github('my-repo/test-jenkins', '*/main')
}
triggers {
scm('H/2 * * * *')
}
steps {
shell(readFileFromWorkspace('jobs/Myjob.groovy'))
build(job: 'PostBuildJob')
}
}