I am using the jenkins dsl plugin multibranchpipeline job(https://jenkinsci.github.io/job-dsl-plugin/#path/multibranchPipelineJob) to create a multi branch pipeline. I have created jenkinsfile which handles the build jobs for each branches. I couldnt figure out how the github push trigger can be enabled through pipeline as code. All the examples I could find are using the jenkins web UI or the pollscm option. Can someone please help on how this can be enabled through code.
Asked
Active
Viewed 1,477 times
1 Answers
2
Project was hosted in github.In jenkins dsl multibranchpipeline, i was using the git branchsource at first. Then push events were not triggering builds. After i started using github branchsource, push events were automatically generating builds.
ie.
multibranchPipelineJob('example') {
branchSources {
git {
id('12121212') // IMPORTANT: use a constant and unique identifier
remote('https://github.com/jenkinsci/job-dsl-plugin.git')
credentialsId('github-ci')
includes('JENKINS-*')
}
}
}
Was changed to
multibranchPipelineJob('example') {
branchSources {
github {
id('23232323') // IMPORTANT: use a constant and unique identifier
scanCredentialsId('github-ci')
repoOwner('OwnerName')
repository('job-dsl-plugin')
}
}
}

aquero
- 843
- 4
- 13
- 30
-
1@JoSSI thanks for pointing it out, I just accepted it as answer :) – aquero May 23 '19 at 07:59
-
Could you please update this answer with actual job-dsl, censored as needed, showing what the correct configuration looks like and where it goes? – JakeRobb Aug 07 '20 at 14:18