pull-request-notifier-for-bitbucket icon indicating copy to clipboard operation
pull-request-notifier-for-bitbucket copied to clipboard

any docs/info on using it w/ a Jenkins Pipeline?

Open kenyee opened this issue 9 years ago • 7 comments

Anyone ever set this up on a Jenkins Pipeline? Can't figure out how to get it to handle the PR branch name and what happens if multiple PRs come in at the same time...

kenyee avatar Aug 18 '16 21:08 kenyee

Been working with this plugin and Jenkins Pipeline. We are using the buildWithParameters API, and passing in information from the PR via this tool to the Jenkins as parameter values. As for multiple PRs, the Jenkins job we have disabled "Do not allow concurrent builds" in Jenkins and run a cluster of build machines linked to Jenkins.

Cardds avatar Sep 28 '16 15:09 Cardds

We do it the same way @Cardds explain. But, we use the throttle plugin to limit the number of concurrent builds per node to 1.

The checkout step in the pipeline would be: checkout scm: [$class: 'GitSCM', branches: [[name: "*/${PULL_REQUEST_FROM_BRANCH}"]], userRemoteConfigs: [[url: "${PULL_REQUEST_FROM_SSH_CLONE_URL}", clean: true, credentialsId: 'a96aece8-fef6-4997-bd74-e4c2e1cc30e4']]]

fredrikand avatar Sep 28 '16 15:09 fredrikand

@fredrikand : how do you get ${PULL_REQUEST_FROM_BRANCH}? and ${PULL_REQUEST_FROM_SSH_CLONE_URL}?

kenyee avatar Sep 28 '16 19:09 kenyee

@kenyee We send them from the notification. The URL we use is https://jenkins.domain.se/job/pull-request/buildWithParameters?token=&${EVERYTHING_URL}

Configure the Jenkins job to be parameterized. In newer Jenkins, you need to configure all params you want to use. All undefined params are discarded.

fredrikand avatar Sep 28 '16 19:09 fredrikand

Hi, To comment @fredrikand 'you need to configure all params', because of this, I logged a question here. Anyone around here, has a solution?

Thanks.

dzonekl avatar Nov 21 '16 12:11 dzonekl

using build with with parameters is the way to go, there are a few other little issues to get the whole thing hanging together, a full write up is here https://dengelonsoftware.blogspot.co.uk/2017/01/jenkins-pull-request-and-pipeline.html

James-Dengel avatar Jul 27 '17 14:07 James-Dengel

We ended up implementing a parameterized seed job that creates (and triggers) a separate pipeline job per pull request via JobDSL. This seed job is triggered by pull-request-notifier-for-bitbucket.

So we have something like when using (bitbucket-)branch-source-plugin but without its bugs and with waymore flexibility (at the cost of a bit more complexity mainly due to the custom seed job).

famod avatar Jul 16 '18 14:07 famod