TransWikia.com

How to have jenkins add a review to a pull request

DevOps Asked by Bruce Becker on August 22, 2021

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:

  1. At the start of the run, create a review
  2. At the end of each stage, post a review comment, with the status of the stage, e.g. "build passed".
  3. 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?

One Answer

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/

Correct answer by froblesmartin on August 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP