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

Retrieving status check values from a pull request off the context? #984

Closed
Schachte opened this issue Aug 14, 2019 · 6 comments

Comments

@Schachte
Copy link

commented Aug 14, 2019

Looking at the payload for a pull request, I'm wondering how to grab the associated list of status checks from this context. For example, a Jenkins build being successful, OWasp being successful, etc.

@issue-label-bot

This comment has been minimized.

Copy link

commented Aug 14, 2019

Issue-Label Bot is automatically applying the label question ❓ to this issue, with a confidence of 0.71. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@gr2m

This comment has been minimized.

Copy link
Contributor

commented Aug 14, 2019

If I recall correctly, you have get the last commit ref of the pull request, and then get all statuses & check runs for that commit.

@Schachte

This comment has been minimized.

Copy link
Author

commented Aug 14, 2019

Do you have any code snippets by chance? Maybe something along these lines?

  const statuses = (await context.github.repos.listStatusesForRef(
    context.repo({ ref: pr.head.ref })
  )).data

Yields:
13:38:51.182Z ERROR probot: {"message":"Resource not accessible by integration","documentation_url":"https://developer.github.com/v3/checks/runs/#list-check-runs-for-a-specific-ref"}

@Schachte

This comment has been minimized.

Copy link
Author

commented Aug 14, 2019

Looks like I'm hitting a 403 GitHub request: GET /repos/:owner/:repo/commits/:ref/check-runs - 403 undefined

I even attached the owner and the repo per the octorestkit docs, but still nothing :(
@gr2m

This comment has been minimized.

Copy link
Contributor

commented Aug 14, 2019

"not accessible by integration" means the app does not have the required permissions. You need read access to

  1. Commit Statuses
  2. Checks

These two things look the same in the UI, but you need two different requests to retrieve them.

I've implemented this in the past but I can't remember where it was, so I don't have a snippet for you, I'm sorry

@Schachte

This comment has been minimized.

Copy link
Author

commented Aug 14, 2019

@gr2m That was it, thanks! I found an old snippet from you actually on another thread and that's exactly what I need. Appreciate the quick response.

@Schachte Schachte closed this Aug 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.