jenkinsci / pipeline-github-plugin

Pipeline: GitHub
https://plugins.jenkins.io/pipeline-github/
MIT License
159 stars 73 forks source link

issueCommentTrigger not working when collaborator is part of GitHub Teams #107

Closed cjoyv closed 1 year ago

cjoyv commented 2 years ago

Jenkins and plugins versions report

Environment ```text Paste the output here ```

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

Linux

Reproduction steps

issueCommentTrigger not working when collaborator is part of GitHub Teams added to the repo

Expected Results

It should consider the members of a team when looking at collaborators

Actual Results

GitHub Team members are not considered as collaborators. Only if a member is directly added to repository as collaborator, issueComments are trigggering the build

Anything else?

No response

emas80 commented 2 years ago

I had the same problem after switching from using a Github token to using a Github App.

I have solved it by adding one more permission to my app - the Administration Read Only

image

The plugin can now read correctly the permissions the user has on the repo.

cjoyv commented 2 years ago

I think my issue is with plugin doesn't supporting Team membership. When a GitHub team is given access to the repo, all of its members gets that access. If collaborator is part of a team with Admin access, the plugin gives an error saying "cjoyv is not a collaborator, and is therefore not authorized to trigger a build"

xocasdashdash commented 2 years ago

Hi there! We're hitting the same issue someone on this ticket and from here it seems to happen too https://github.com/jenkinsci/pipeline-github-plugin/issues/104#issuecomment-920833823

Seems like the way the underlying library fetches collaborators is not team membership friendly. Could we add a flag to disable it as suggested? Another approach could be to implement the flow "correctly", check the user team, get the team permissions and see if any of the teams can write on the repository

nick-tripp commented 2 years ago

I'm also experiencing this issue in my org - definitely seems like good bug to fix

xocasdashdash commented 2 years ago

My PR #111 fixes it, but not sure how much time it's going to take to get this merged 😕

snorlaX-sleeps commented 2 years ago

I wonder if there is anyone we could tag for your PR @xocasdashdash - the fix listed above (add more app permissions) doesn't work when using teams, the user has to be directly added to the repo which wouldn't work in my use-case

xocasdashdash commented 1 year ago

@snorlaX-sleeps in the PR #111 Aaron posted a link to test it out, if you can validate the plugin we can probably get this merged soon!

xocasdashdash commented 1 year ago

This issue can be closed as #111 has been merged. Not sure when it's going to be released though @aaronwalker

aaronwalker commented 1 year ago

@xocasdashdash release published https://github.com/jenkinsci/pipeline-github-plugin/releases/tag/2.8-141.7e985db66f30