简体   繁体   中英

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

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')
    }
}

Use upstream which adds the "Build after other projects are built" trigger. see https://jenkinsci.github.io/job-dsl-plugin/#path/job-triggers-upstream

def gitUrl = 'GIT_URL'

job('unit-tests') {
    scm {
        git(gitUrl)
    }
    triggers {
        buildResult('H/* * * * *') {
            upstream('Demo', 'UNSTABLE')
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM