Multibranch GitHub Branch Source Jenkinsfile woes - extreme confusion

96 views
Skip to first unread message

Jason Antman

unread,
May 23, 2017, 7:33:22 AM5/23/17
to Jenkins Users
Hello,

I'm just getting started with Jenkinsfiles (Scripted) after using Job DSL for a few years. I'm playing around with the Multibranch Pipeline plugin (using GitHub Branch Source), as it seems like an incredibly easy way to do things. I've already got a build running in a few dozen lines that would've taken me a lot more with Job DSL.

I have one bit of extreme confusion though:

I create a new "Multibranch Pipeline" job with configuration "by Jenkinsfile", and configure it with a GitHub Branch Source. That's wonderful; it picks up all my branches and builds them as desired.

However, the default configuration of the GitHub Branch Source plugin (as seen through the UI) has "Build origin branches also filed as PRs" checked (true) and "Build origin PRs (merged with base branch)" unchecked (false). I can't seem to figure out how to use my Jenkinsfile to change those settings. I tried using the properties construct:

properties([
 
[
    $class
: 'org.jenkinsci.plugins.github_branch_source.GitHubSCMSource',
    buildOriginBranch
: true,
    buildOriginBranchWithPR
: false,
    buildOriginPRMerge
: true,
    buildOriginPRHead
: false,
    buildForkPRMerge
: true,
    buildForkPRHead
: false
 
]
])

But that just results in

java.lang.ClassCastException: org.jenkinsci.plugins.github_branch_source.GitHubSCMSource cannot be cast to hudson.model.JobProperty

We only define our job configuration in code (currently using Job DSL almost everywhere), and I'm trying to work on a first example of Jenkinsfiles, but can't get past this one stumbling block.

I've spent over 8 hours on this by now, to no avail. I see that the pipeline reference for workflow-multibranch and for workflow-cps-global-lib make reference to GitHubSCMSource, and appear to have options for what I want, but I can't seem to find any examples of using either that make sense to me and couldn't get it working on my own (partly because the formatting of those documentation pages seems to be broken).

Emphatic thanks for anyone who can point me in the right direction or offer help with this.

Thanks,
Jason Antman
Reply all
Reply to author
Forward
0 new messages