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

The plugin triggers builds for PRs with same number in different repositories #65

Open
CiocoiuRadu opened this issue Oct 11, 2023 · 4 comments
Labels

Comments

@CiocoiuRadu
Copy link

Jenkins and plugins versions report

Environment

Jenkins: 2.346.3
OS: Linux - 4.14.326-245.539.amzn2.x86_64
Java: 11.0.16 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)

.....
branch-api:2.1071.v1a_188a_562481
git:4.14.3
git-client:3.13.1
github:1.34.5
github-api:1.303-400.v35c2d8258028
github-branch-source:1696.v3a_7603564d04
github-checks:1.0.19
github-pr-comment-build:96.v9ff13b69dd66
......

What Operating System are you using (both controller, and any agents involved in the problem)?

OS: Linux - 4.14.326-245.539.amzn2.x86_64

Reproduction steps

  1. Create Github organization with several repositories containing jenkinsfiles
  2. Either configure organization webhook or 1 repository webhook with "Issue Comments" Event
  3. Create and configure Jenkins "Organization Folder" job
  4. Open a pull request in multiple repositories, so that multiple repositories have the same PR number (e.g. pull request Support GH organization folders #1 on multiple repos)
  5. Trigger a scan in the Jenkins organization to detect and create jobs for these repositories
  6. Post a comment in one of these repositories with the keyword configured in the plugin

Expected Results

The expected result would be that a build is triggered only in the repository in which the comment was posted

Actual Results

Builds are triggered for every "repository" in Jenkins that matches the PR number which sent the Github event
image

In the image above, a comment with the expected keyword was posted on first PR in the sw-prj-repo3 repository

Anything else?

Here is a log snippet:
image

Is this the intended behavior?

@bluesliverx
Copy link
Contributor

Definitely not intended behavior. Trying to figure out what is different in your setup though, since we don't hit this problem and we have thousands of PRs across hundreds of repositories.

@bluesliverx
Copy link
Contributor

bluesliverx commented Oct 11, 2023

Ah, I missed originally that this is for a GitHub Organization Folder job. How did you configure this plugin for the folder? See also #1 as this describes some of what might be involved. Otherwise I think you are the first one (or the first to report) to try this.

@CiocoiuRadu
Copy link
Author

Hello,
Thank you for the fast reply!

In the Jenkins organization folder, we just have the following (relevant?) settings:
image

image

I think these are the most relevant ones. I also have "Pull request" event configured in the Github webhook, and if I remove the "Trigger build on PR comment", a build will be triggered if I update one of the PRs, but it will trigger only for the relevant repo.

I had a quick look in the plugin code, as I was looking for the "Triggered build for <...>" source (from the log snippet), and if I interpreted it correctly, it will get all jobs, and if it matches the PR number, and the configured keyword, it will start a build:
https://github.com/jenkinsci/github-pr-comment-build-plugin/blob/fef405665ee23acb44dea17ec12a36a887c58153/src/main/java/com/adobe/jenkins/github_pr_comment_build/IssueCommentGHEventSubscriber.java#L138C42-L138C42

@bluesliverx
Copy link
Contributor

I believe this is a misconfigured. As mentioned in #1, the trigger must be added in the Jenkinsfile and not on the organization folder itself. I think what is happening (just a guess though without actually seeing the config) is that the folder is the GitHubSCMSource and since it has the property on it, it triggers everything underneath it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants