Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes intermittent multiple job invocations #41

Merged
merged 1 commit into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ protected void onEvent(GHEvent event, String payload) {
@Override
public void run() {
boolean jobFound = false;
topLevel:
for (final SCMSourceOwner owner : SCMSourceOwners.all()) {
for (SCMSource source : owner.getSCMSources()) {
if (!(source instanceof GitHubSCMSource)) {
Expand Down Expand Up @@ -161,13 +162,14 @@ public void run() {
changedRepository.getRepositoryName()
}
);
break topLevel;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly this has broken the following workflow, in which we expect multiple builds to be triggered:

  • we have multiple jobs which each define triggerPRCommentBranchProperty e.g. one with commentBody(".*foo this please.*") and another with commentBody(".*bar this please.*")
  • it was previously possible to comment on a PR like this and both jobs would be triggered:
foo this please
bar this please
  • however now only 1 of them is triggered (whichever one the for (Job... loop gets to first)

The workaround is of course to do a separate comment for each one, but when you want to trigger 5 different custom test runs, this is a 5x increase in (a) effort to initiate, and (b) the amount of email spam sent to others watching the PR.

Perhaps if instead of doing break it instead checked whether job had already been scheduled, that would be a way of avoiding duplicates without stopping multiple different jobs being scheduled from the same comment?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have been seeing issues for weeks with similar problems, and your comment just made me connect it to this PR. I'm downgrading the plugin on our Jenkins to verify that this is indeed the cause.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sparrowt please open a new issue.
As I mentioned in the comment #41 (comment),
this would break the cases where multiple legitimate jobs would be triggered by a single comment.
Unfortunately I don't have the environment to test this on.
This PR fixes the 99% case where this plugin was broken for a long time, as reported in multiple issues by multiple people.

I can propose a short-term fix by adding a checkbox that turns off one-per-comment build (default would be on) since that's 99% of the cases.

In the future if there is more interest to see what actually causes duplicate builds maybe there would be more time to take this on

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I never got round to this - however it looks like #49 was opened and #48 fixes it (released in https://github.com/jenkinsci/github-pr-comment-build-plugin/releases/tag/82.v986d7874d9c5) so thank you!

} else {
LOGGER.log(Level.FINER,
"Issue comment does not match the trigger build string ({0}) for {1}",
new Object[] { expectedCommentBody, job.getFullName() }
);
break;
}
break;
}

if (!propFound) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ protected void onEvent(GHEvent event, String payload) {
@Override
public void run() {
boolean jobFound = false;
topLevel:
for (final SCMSourceOwner owner : SCMSourceOwners.all()) {
for (SCMSource source : owner.getSCMSources()) {
if (!(source instanceof GitHubSCMSource)) {
Expand All @@ -118,7 +119,7 @@ public void run() {
propFound = true;
ParameterizedJobMixIn.scheduleBuild2(job, 0,
new CauseAction(new GitHubPullRequestReviewCause(pullRequestUrl)));
break;
break topLevel;
}

if (!propFound) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ protected void onEvent(GHEvent event, String payload) {
@Override
public void run() {
boolean jobFound = false;
topLevel:
for (final SCMSourceOwner owner : SCMSourceOwners.all()) {
for (SCMSource source : owner.getSCMSources()) {
if (!(source instanceof GitHubSCMSource)) {
Expand All @@ -134,7 +135,7 @@ public void run() {
propFound = true;
ParameterizedJobMixIn.scheduleBuild2(job, 0,
new CauseAction(new GitHubPullRequestUpdateCause(pullRequestUrl)));
break;
break topLevel;
}

if (!propFound) {
Expand Down