-
Notifications
You must be signed in to change notification settings - Fork 98
Correction of rebuild on comment on wrong pipeline #290
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
Correction of rebuild on comment on wrong pipeline #290
Conversation
@@ -56,29 +58,33 @@ public void isMatch() { | |||
if (gitLabSCMSource.getProjectId() == getPayload().getMergeRequest().getTargetProjectId() | |||
&& isTrustedMember(gitLabSCMSource, sourceContext.getOnlyTrustedMembersCanTrigger())) { | |||
for (Job<?, ?> job : owner.getAllJobs()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this for, we loop to all jobs. Even out of the projectId. And there isn't more check after with the payload
if (MultiBranchProject.class.isAssignableFrom(job.getParent().getClass()) ) { | ||
MultiBranchProject parentJob = (MultiBranchProject) job.getParent(); | ||
if (parentJob.getSCMSource(gitLabSCMSource.getId()) == gitLabSCMSource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I try to check the link between the source of the payload and the job in the for.
I don't know if there is a better solution
"MR comment does not match the trigger build string ({0}) for {1}", | ||
new Object[] { expectedCommentBody, job.getFullName() }); | ||
} | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this break, only one job can be executed.
I'm wondering if it is possible to have 2 multi branch pipelines with the same project?
Because if it can, this break stop the wake up of the second pipeline in case of comment
filtered jenkins jobs with SCMSource of the payload on comment trigger
66cdf19
to
bc67102
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems safer way of handling it.
filtered jenkins jobs with SCMSource of the payload on comment trigger
close #256
Be careful with this PR. There isn't a lot of code but the fix seems very important I think.
If several people can test it, It'll be appreciated.
In GitLabMergeRequestCommentTrigger class to find which job build depending on the payload information of the webhook. There isn't link between GItlab Project Id and Jenkins jobs. I add a if between these 2 objects with the job parent Item.
To reproduce the previous problem :
Be careful to test it with any other pipeline executed.