How to configure a Jenkins pipelineJob via jenkins job dsl with github pull request builder?

963 Views Asked by At

How can I configure a jenkins pipelineJob via jenkins job dsl with the github pull request builder?

I have tried:

pipelineJob("Test GHPRB") {
        properties {
            pipelineTriggers {
                triggers {
                    githubPullRequest {
                        useGitHubHooks()
                        orgWhitelist('orgName')
                        allowMembersOfWhitelistedOrgsAsAdmin()
                    }
                }
            }
        }
        definition { ... }
    }

But it fails with an error:

No signature of method: javaposse.jobdsl.plugin.structs.DescribableListContext.githubPullRequest() is applicable for argument types: (usIntJobs$_run_closure1$_closure3$_closure5$_closure6$_closure7) values: [usIntJobs$_run_closure1$_closure3$_closure5$_closure6$_closure7@72ad1a0f]

As a bonus, how would I configure it via jenkins job dsl like so: enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

As NoamHelmer said in comments,

Go to the DSL API viewer on your server (https://your.jenkins.installation/plugin/job-dsl/api-viewer/index.html) and search for ghprbTrigger thats the one you need for your pipeline job.

Which was very useful. For completeness, will post the job dsl configuration for above.

This is under pipelineJob.properties:

ghprbTrigger {
    adminlist("myAdmin")
    whitelist("")
    orgslist('orgName')
    cron("")
    triggerPhrase(triggerPhraseStatement)
    onlyTriggerPhrase(true)
    useGitHubHooks(true)
    permitAll(false)
    autoCloseFailedPullRequests(false)
    displayBuildErrorsOnDownstreamBuilds(true)
    commentFilePath("")
    skipBuildPhrase("")
    blackListCommitAuthor("")
    allowMembersOfWhitelistedOrgsAsAdmin(true)
    msgSuccess("")
    msgFailure("")
    commitStatusContext("")
    gitHubAuthId("")
    buildDescTemplate("")
    blackListLabels("")
    whiteListLabels("")
    includedRegions("")
    excludedRegions("")
}