snippetMinor
How to have jenkins add a review to a pull request
Viewed 0 times
pulljenkinsrequesthowreviewhaveadd
Problem
I have a Jenkins instance, with credentials for a "robot" github account, which we use to interact with the GitHub API as a team. Typically, jobs are defined as declarative pipelines. I am looking for the correct syntax to perform the following steps:
I can allow scripted steps, but the pipeline as a whole should be declarative. No shared libraries, and preferably only using commonly-used plugins.
(update with what I have tried)
I have tried using the pipeline github plugin's review method:
naively, but this throws errors.
What would be the correct syntax here?
- At the start of the run, create a review
- At the end of each stage, post a review comment, with the status of the stage, e.g. "build passed".
- If all of the stages pass, approve the pull request.
I can allow scripted steps, but the pipeline as a whole should be declarative. No shared libraries, and preferably only using commonly-used plugins.
(update with what I have tried)
I have tried using the pipeline github plugin's review method:
pullRequest.review('APPROVE')naively, but this throws errors.
What would be the correct syntax here?
Solution
I guess the simplest and direct solution would be to use GitHub API: https://docs.github.com/en/rest/reference/pulls#create-a-review-for-a-pull-request
But for the requirement you have, PR checks is usually the way to go and you have a plugin that does the API communication for you: https://www.jenkins.io/doc/pipeline/steps/pipeline-githubnotify-step/
But for the requirement you have, PR checks is usually the way to go and you have a plugin that does the API communication for you: https://www.jenkins.io/doc/pipeline/steps/pipeline-githubnotify-step/
Context
StackExchange DevOps Q#11979, answer score: 7
Revisions (0)
No revisions yet.