Search code examples
jenkinsjenkins-job-dsl

Jenkins project generated by Job DSL is not triggered.


I have a project, named Demo, which doesn't do anything in particular.

I have a DSL script, like the following:

def gitUrl = 'GIT_URL'

job('unit-tests') {
    scm {
        git(gitUrl)
    }
    triggers {
        buildResult('H/* * * * *') {
            combinedJobs()
            triggerInfo('Demo', BuildResult.SUCCESS, BuildResult.UNSTABLE)
        }
    }
}

Now what I'm wanting to do, is that when the Demo project runs successfully (it checks out a PHP application from Github), I want the unit-tests job to run.

Currently, when the Demo project is built, the unit-tests job never gets run.

I'm guessing my DSL script is incorrect, but I'm not sure why


Solution

  • I can reproduce your problem. The check box is not set when running the seed job for the first time. But it's set after running the seed job a second time. Must be a problem in the BuildResultTrigger plugin. Please file a bug report in the Jenkins JIRA: https://issues.jenkins-ci.org/projects/JENKINS

    But you do not necessarily need to use the BuildResultTrigger plugin. You can use the built-in "Build after other projects are built" option, see https://jenkinsci.github.io/job-dsl-plugin/#path/job-triggers-upstream.

    job('unit-tests') {
        triggers {
            upstream('Demo', 'UNSTABLE')
        }
    }