简体   繁体   中英

Jenkins Pipeline - automatic build triggering on GitHub PRs?

I am converting existing Jenkins jobs in the new Pipeline implementation using Jenkinsfiles. However, what is not obvious at all is how to do the most basic triggering on pull requests. My existing BuildFlows are configured to build GitHub PR branches automatically when ever a PR is opened against the master branch. How do you set this up via Pipeline as Code?

Since the Jenkinsfile lives in SCM, the pull request triggering obviously cannot be defined in that file (chicken or the egg problem...).

I've tried using the GitHub Organization folder plugin, but it's not clearly documented and still isn't obvious how to enable automatic building of PRs against master. The plugin scans my repo and creates jobs for existing branches, but I don't see how I can get it to build PRs as they are opened .

Anyone figured out how to achieve this? I really like the new Pipeline as Code idea, but the configuration is very non-intuitive.

I've achieved what you seem to want to do simply by creating a "git hub organization" project in Jenkins. If you're running the latest and greatest Jenkins then when you go to create a new project "Git Hub Organization" is one of the options. When chosen you are given the options to choose your organization / repo and there are many build options including PR related ones. Mind you none of this is your Jenkinsfile per say. Its all done in the project config. Hope this helps.

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