[JIRA] (JENKINS-59833) Stash Pull Request Builder Multiple PR in single build

0 views
Skip to first unread message

upkarrai@gmail.com (JIRA)

unread,
Oct 17, 2019, 5:04:03 PM10/17/19
to jenkinsc...@googlegroups.com
Upkar Rai created an issue
 
Jenkins / Bug JENKINS-59833
Stash Pull Request Builder Multiple PR in single build
Issue Type: Bug Bug
Assignee: Jakub Bochenski
Components: stash-pullrequest-builder-plugin
Created: 2019-10-17 21:03
Priority: Major Major
Reporter: Upkar Rai

Ref : https://github.com/HB-2012 comments on https://gitter.im/jenkinsci/stash-pullrequest-builder-plugin

Hi there. In my organization I have a PR pipeline set up using the experimental support for pipelines. I keep noticing that our job keeps building a bunch of PRs in a single build, which is undesirable since the Stash Notifier plugin doesn't understand this and only reports a successful build for a single PR, even tho apparently the PR builder plugin recognizes it has started builds for multiple PRs. We're dealing with a huge amount of PRs here (about 20-30 developers and therefor we can have 40 PRs open at any given time).

Git settings are configured as per the manual and we've set the following configuration for the Git PR builder plugin
Is this standard behavior for the Stash PR builder or am I missing something?

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

bochenski.kuba+jenkins@gmail.com (JIRA)

unread,
Oct 18, 2019, 6:50:05 AM10/18/19
to jenkinsc...@googlegroups.com
Jakub Bochenski assigned an issue to Unassigned
Change By: Jakub Bochenski
Assignee: Jakub Bochenski

bochenski.kuba+jenkins@gmail.com (JIRA)

unread,
Oct 18, 2019, 6:53:02 AM10/18/19
to jenkinsc...@googlegroups.com
Jakub Bochenski commented on Bug JENKINS-59833
 
Re: Stash Pull Request Builder Multiple PR in single build

I don't expect I'll find time to investigate this any time soon.
If you can investigate the issue and file a PR I'll be happy to review it (that's what "experimental support" is about)

plroskin@gmail.com (JIRA)

unread,
Oct 19, 2019, 6:45:03 PM10/19/19
to jenkinsc...@googlegroups.com

What's the version of the plugin? What's the version of Jenkins? I cannot reproduce the issue. It a build has multiple causes of the type StashCause, that breaks a lot of assumptions in the plugin. But I don't see how it can happen.

upkarrai@gmail.com (JIRA)

unread,
Oct 19, 2019, 9:00:03 PM10/19/19
to jenkinsc...@googlegroups.com

Atlassian Bitbucket v5.12.0
Jenkins ver. 2.190.1
Stash Pullrequest Builder Plugin 1.13

upkarrai@gmail.com (JIRA)

unread,
Oct 19, 2019, 9:05:02 PM10/19/19
to jenkinsc...@googlegroups.com

Case 1

2 fresh commits to 2 branches. Set polling to 3 mins . Create PRs.

Polling log will show 2 Prs and 2 need building then start a single build but have noth PRs in the descripting 

 

Case 2 

So 2 fresh commits to 2 branches. Set polling to 1 mins . Create 1 PRs. in build  logs Commit is from 1st PR

Let jenkins start this job

Open another PR - first job is aborted and another created with both PRs in build logs Commit is from 1st PR

upkarrai@gmail.com (JIRA)

unread,
Oct 19, 2019, 9:15:01 PM10/19/19
to jenkinsc...@googlegroups.com
Upkar Rai updated an issue
 
Change By: Upkar Rai
Attachment: image-2019-10-19-18-14-43-573.png

upkarrai@gmail.com (JIRA)

unread,
Oct 19, 2019, 9:16:02 PM10/19/19
to jenkinsc...@googlegroups.com

upkarrai@gmail.com (JIRA)

unread,
Oct 19, 2019, 9:16:03 PM10/19/19
to jenkinsc...@googlegroups.com
Upkar Rai updated an issue
Change By: Upkar Rai
Attachment: image-2019-10-19-18-15-07-799.png

upkarrai@gmail.com (JIRA)

unread,
Oct 19, 2019, 9:18:01 PM10/19/19
to jenkinsc...@googlegroups.com
Upkar Rai edited a comment on Bug JENKINS-59833
 
Re: Stash Pull Request Builder Multiple PR in single build
I got the latest code and built it and still the same issue.

See the log.txt

The PR are from branch bugfix/upkar2 and bugfix/upkar3 into bugfix/upkar.

See Screen shot of 1 PR, Polling log, job and build log. 

 

!image-2019-10-19-18-15-07-799.png!

!image-2019-10-19-18-14-43-573.png!

upkarrai@gmail.com (JIRA)

unread,
Oct 19, 2019, 9:19:02 PM10/19/19
to jenkinsc...@googlegroups.com
Upkar Rai edited a comment on Bug JENKINS-59833
I got the latest code and built it and still the same issue.

See the log.txt

The PR are from branch bugfix/upkar2 and bugfix/upkar3 into bugfix/upkar.

See Screen shot of 1 PR, Polling log, job and build log. 

 

!image-2019-10-19-18-15-07-799.png |width=442,height=423 !

!image-2019-10-19-18-
14 18 - 43 29 - 573 862 .png |width=1263,height=1424 !

upkarrai@gmail.com (JIRA)

unread,
Oct 19, 2019, 9:19:03 PM10/19/19
to jenkinsc...@googlegroups.com
Upkar Rai updated an issue
Change By: Upkar Rai
Attachment: image-2019-10-19-18-14-43-573.png

upkarrai@gmail.com (JIRA)

unread,
Oct 19, 2019, 9:21:02 PM10/19/19
to jenkinsc...@googlegroups.com
Upkar Rai updated an issue
Change By: Upkar Rai
Attachment: config.xml.txt

plroskin@gmail.com (JIRA)

unread,
Oct 20, 2019, 1:02:03 AM10/20/19
to jenkinsc...@googlegroups.com
Pavel Roskin commented on Bug JENKINS-59833
 
Re: Stash Pull Request Builder Multiple PR in single build

I was able to reproduce the issue right away after downgrading Jenkins from 2.200 to 2.190.1. It was a full reinstall, so I'm not sure the issue is with the Jenkins code and not with some obscure configuration difference.

Apparently, Jenkins decides that two different calls to ParameterizedJobMixIn.scheduleBuild2() in StashRepository#startJob() want to trigger the same build despite having the same causes. The parameters are the same (none). The environment is populated once the build exists.

Adding the "sourceCommitHash" string parameter is an effective workaround, as it makes the builds different at the time when they are scheduled.

upkarrai@gmail.com (JIRA)

unread,
Oct 20, 2019, 2:35:05 AM10/20/19
to jenkinsc...@googlegroups.com

For me I did not upgrade anything for a 6 months except bitbucket. I only upgraded to 2.190 after this problem started. I will try to upgrade jenkins and see it it goes away.

if I add the "sourceCommitHash" string parameter. Does it still cancel duplicate builds from same PR but new Commits ?

upkarrai@gmail.com (JIRA)

unread,
Oct 20, 2019, 2:42:02 AM10/20/19
to jenkinsc...@googlegroups.com

Confirmed : Adding sourceCommitHash is a workaround.

Not confirmed  : Will it stop builds if new commit is made to the PR

plroskin@gmail.com (JIRA)

unread,
Oct 20, 2019, 2:55:03 AM10/20/19
to jenkinsc...@googlegroups.com

Looking at the Jenkins code, specifically at Queue#scheduleInternal(), I see that there is a mechanism to decide whether to schedule a new build. Every item in the queue is asked whether to schedule a new build given the list of actions. If a queue item responds through shouldSchedule() that the new build should not be scheduled, that queue item absorbs the new actions without scheduling the build. Only actions that implement QueueAction interface are involved in deciding whether to schedule a build.

That mechanism could be used to replace StashRepository#cancelPreviousJobsInQueueThatMatch() in a safer manner. Cancelling a queue item is risky because the new build can fail to be scheduled (e.g. Jenkins is being rebooted). Instead, the new build would replace data (StashCause) in the existing queue item.

Git plugin implements RevisionParameterAction that is added to the actions when scheduling. It's responsible for deciding whether to schedule a new build based on the git revision. It could serve as an example.

plroskin@gmail.com (JIRA)

unread,
Oct 20, 2019, 7:21:04 PM10/20/19
to jenkinsc...@googlegroups.com

bochenski.kuba+jenkins@gmail.com (JIRA)

unread,
Oct 21, 2019, 6:44:03 AM10/21/19
to jenkinsc...@googlegroups.com
Jakub Bochenski started work on Bug JENKINS-59833
 
Change By: Jakub Bochenski
Status: Open In Progress

bochenski.kuba+jenkins@gmail.com (JIRA)

unread,
Oct 21, 2019, 6:44:03 AM10/21/19
to jenkinsc...@googlegroups.com

Upkar Rai can you please check if the incremental build fixes the issue for you? It should be available soonish, once https://ci.jenkins.io/job/Plugins/job/stash-pullrequest-builder-plugin/job/PR-151/ completes.

bochenski.kuba+jenkins@gmail.com (JIRA)

unread,
Oct 21, 2019, 6:44:03 AM10/21/19
to jenkinsc...@googlegroups.com

upkarrai@gmail.com (JIRA)

unread,
Oct 21, 2019, 3:19:02 PM10/21/19
to jenkinsc...@googlegroups.com

bochenski.kuba+jenkins@gmail.com (JIRA)

unread,
Oct 22, 2019, 8:32:02 AM10/22/19
to jenkinsc...@googlegroups.com

Upkar Rai did you actually check if the fix works for you?

upkarrai@gmail.com (JIRA)

unread,
Oct 22, 2019, 2:02:02 PM10/22/19
to jenkinsc...@googlegroups.com

I have manually built and tested the open PR commit on my dev machine and it works. I dont want to say it works till I can have an official build

upkarrai@gmail.com (JIRA)

unread,
Oct 22, 2019, 2:08:04 PM10/22/19
to jenkinsc...@googlegroups.com
Upkar Rai edited a comment on Bug JENKINS-59833
I have manually built and tested the open PR commit on my dev machine and it works. I dont want to say it works till I can have an official actual build

plroskin@gmail.com (JIRA)

unread,
Oct 22, 2019, 2:59:02 PM10/22/19
to jenkinsc...@googlegroups.com

Maven is actually very good at reproducible builds. If the revision shown under Manage Jenkins -> Manage Plugins > Installed is the one you intended to test, (that would be d3bba2491043066fb793fb32fefa6f7dedf2aa0b currently), I assume it's a good test. You would see just the beginning of the hash, that's OK.

upkarrai@gmail.com (JIRA)

unread,
Oct 22, 2019, 3:37:02 PM10/22/19
to jenkinsc...@googlegroups.com

Sorry if I was not clear. I did a mvn hpi:run for commit  d3bba2491043066fb793fb32fefa6f7dedf2aa0b and test it. Works as expected.

plroskin@gmail.com (JIRA)

unread,
Oct 22, 2019, 4:52:02 PM10/22/19
to jenkinsc...@googlegroups.com

Did you actually set up a job and verify that queue items don't get folded?

By the way, I wasn't aware of "mvn hpi:run", that's a great way to verify changes quickly! I was able to configure a job and test it with two pull requests. I saw them in the queue, and they were run separately.

I didn't see the Credentials menu the first time, but it appeared after the restart.

upkarrai@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:03:02 PM10/22/19
to jenkinsc...@googlegroups.com

bochenski.kuba+jenkins@gmail.com (JIRA)

unread,
Oct 23, 2019, 8:48:02 AM10/23/19
to jenkinsc...@googlegroups.com

FTR you could also use the incremental builds https://jenkins.io/blog/2018/05/15/incremental-deployment/
I deploy Jenkins from a docker container it's much more convinient to just add a line like :incrementals;org.jenkins-ci.plugins;VERSION

bochenski.kuba+jenkins@gmail.com (JIRA)

unread,
Oct 23, 2019, 9:14:02 AM10/23/19
to jenkinsc...@googlegroups.com
Jakub Bochenski resolved as Fixed
 

Released as v. 1.14

Change By: Jakub Bochenski
Status: In Progress Resolved
Resolution: Fixed
Reply all
Reply to author
Forward
0 new messages