What is the DSL for Jenkins downstream (post build action) job?

5k views Asked by At

I would like to do this, but in the Jenkins DSL:

enter image description here

If found somewhere this, but it's not working:

job('ps-first') {
    steps { shell('echo "landing"') }
    postBuildSteps { ...run other job here... }
        configure {
            it <<
                    'runPostStepsIfResult' { name('SUCCESS') }
        }
}
3

There are 3 answers

0
Joaquín On BEST ANSWER

As explained in https://jenkinsci.github.io/job-dsl-plugin/#path/freeStyleJob-publishers-downstream

job('ps-first') {
...
    publishers {
        downstream('ps-archive', 'SUCCESS')
    }
}
0
Babu On

I found what I was looking for! enter image description here

First step was look how the xml is generated from my UI -> go to url and replace config path with config.xml Then find publishers in the documentation enter image description here

0
Rik On

Please take a look at https://your-jenkins-server/pipeline-syntax on your own jenkins server. This snippet generator can create a lot of snippets based on the plugins you have installed.

For your post-build step I think what you are looking for is

build job: 'ps-archive', parameters: [
    string(name: 'Param1', value: 'someValue'),
    booleanParam(name: 'Bool', value: false,
    ...
    ], quietPeriod: 2, wait: false

You can leave out quietPeriod if it should start immediate.