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

Avoid builds for closed/merged PR #332

Open
prawen opened this issue Jul 28, 2020 · 5 comments
Open

Avoid builds for closed/merged PR #332

prawen opened this issue Jul 28, 2020 · 5 comments

Comments

@prawen
Copy link

prawen commented Jul 28, 2020

Hello,

I'm new to this plugin and really appreciate your help here.

I have configured the plugin as per the instructions provided.
Client cache is set to 20.
My trigger event is "Comment matched to Pattern"
My webhook settings on gitlab.com sends below events
a. Issue Comments
b. Pull requests

Expected flow:

  1. User raises PR
  2. User makes a comment as per the pattern and the build should be triggered

Actual result:
When a comment matches my pattern, build is getting triggered and the build status is being reported before and after the build. This is working as per my expectation.

Issue I'm facing

  1. When the pipeline is still running and by mistake the admin merges the PR, below flow is causing loop of builds
    a. Admin merges the PR
    b. Pipeline reports the status on the closed/merged PR
    c. Github PR polling log says "Change found and comment pattern matched"
    d. Build triggers
    e. Build finishes and Pipeline reports the status on the closed/merged PR
    f. Github PR polling log says "Change found and comment pattern matched"
    g. This goes in a loop. Last night I had 200 builds triggered and finally when I cancel the queued build before even running, this loop got stopped.

What I'm expecting

  1. Build should not trigger for closed/merged PR irrespective of any changes made to PR like commenting,adding approver or changing some meta data
@prawen
Copy link
Author

prawen commented Jul 28, 2020

One more observation which resulted into same issue again.

Flow:

  1. One of the user visited closed/merged PR and changed some metadata like PR template
  2. Github sent webhook event
  3. Please note the user changed only meta data like PR template and did not comment
  4. Jenkins triggered build and it went on in a loop as I described earlier. It only stopped when I cancelled the build before it even executed.
  5. In both the cases, I have observed this on closed/merged PR

Is there anyway we can ignore the build trigger if PR is closed/merged ?

@prawen
Copy link
Author

prawen commented Aug 7, 2020

@KostyaSha Can you please help ?

@prawen
Copy link
Author

prawen commented Aug 29, 2020

@KostyaSha I'm still facing this issue. Any help would be really appreciated.

@KostyaSha
Copy link
Owner

KostyaSha commented Aug 30, 2020

Probably try to add one more criteria "Pull Request Closed" that will skip PR builds.

Though Pipeline reports the status on the closed/merged PR - that's ok. That will probably change in GitHub API timestamp of repository. But then trigger will check and compare the date of the last comment. It shouldn't see new comments.
The state is saved in job directory i.e. https://github.com/KostyaSha/github-integration-plugin/blob/master/github-pullrequest-plugin/src/test/resources/org.jenkinsci.plugins.github.pullrequest.GitHubPRRepository.runtime.xml#L23 could you verify manually before and after triggering?

@zhengliyuan1987
Copy link

zhengliyuan1987 commented Dec 4, 2020

is this issue solved? @KostyaSha

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

No branches or pull requests

3 participants