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 
<https://jenkins.io/doc/pipeline/steps/workflow-multibranch/#code-properties-code-set-job-properties>
 
and for workflow-cps-global-lib 
<https://jenkins.io/doc/pipeline/steps/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

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/97a8e891-21ea-484f-9b6f-233a3d5f45d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to