Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add comment to Github pull request from Jenkins pipeline

I am wondering if there is already a way to update a Github (Enterprise) pull request with a comment within the Jenkins Pipeline syntax. I have it already updating it with the build status of success or failed automatically but I also want to post a comment with the test results and code coverage or the reason why the build failed. Before I start to write my own function in groovy calling the REST API of github to do this I wanted to make sure there wasn't already an easier way say like a plugin that had this function.

like image 799
mitchellmaler Avatar asked Jan 14 '18 06:01

mitchellmaler


People also ask

How do I add a comment to a GitHub pull request?

Adding line comments to a pull requestUnder your repository name, click Pull requests. In the list of pull requests, click the pull request where you'd like to leave line comments. On the pull request, click Files changed. Hover over the line of code where you'd like to add a comment, and click the blue comment icon.

What is a pull request comment?

A pull request (PR) is a process when new code is reviewed before it should be merged to develop a branch or master branch in a Git repository like GitHub. The author creates a PR, while a reviewer reviews a PR. A PR could be time-consuming, annoying, or even nerve-racking if done wrong.

How do I run a Jenkins pipeline on a pull request?

Configure your pipelineOn the Datalog Tagging tab, check “GitHub project”, and put your project URL in the field. On the Build Triggers tab, check “GitHub Pull Request Builder”. Then the GitHub API credentials is automatically filled in. Make sure the Admin list is filled in with at least one admin name.


1 Answers

Check first if the "Adding a comment" section of the jenkinsci/pipeline-github-plugin would work for you:

def comment = pullRequest.comment('This PR is highly illogical..')

There are however issues associated with that approach (#85, #33)

Check however that you have the pipeline-github installed first.

like image 101
VonC Avatar answered Oct 21 '22 15:10

VonC