Is there a Jenkins plugin / tool to monitor PR comments?

179 Views Asked by At

I currently have a jenkins casc instance that is not accessible from the internet. Therefore, I have not been able to trigger builds using a webhook. However, I am still able to set up a 'Poll SCM' build trigger, so that Jenkins will automatically check the most recent sha, and trigger a job if the sha changes.

I was curious if there is a similar feature for Pull Requests. Ideally, I would like to trigger a pull-request anytime a comment is made by a trusted individual. Is there a mechanism to poll github PR comments without needing the cluster to be accessible from the internet?

3

There are 3 best solutions below

0
M B On

There is no plugin readily available that I know of. However, you can do it in the same way you did it with polling SCM; by polling the GitHub comments. While your Jenkins instance can't be accessed from GitHub, Jenkins can access your GitHub instance. So what you have to do is create a pipeline that runs periodically (every couple of minutes) that calls the GitHub PR comment API, and checks to see if a comment matching whatever words you are looking for in a build has been made. Since the response of the call also returns the user information, you can easily check to see if the user is within your list of trusted individuals.

You can also restrict the responses by when the comment was created so that you don't repeatedly run the build because the comment is there. The creation time of the comment is also included in the response.

2
VANAN On

There is a ghprb plugin that polls the GH repository for pull request changes, so it is not necessary to have the jenkins instance exposed to the internet.

You can configure an admin list, where one of the admins need to post a predefined phrase as a comment to trigger the job ("ok to test" by default), it also supports retriggering the job by adding a comment to the PR.

0
Robert Kovalauskis On

Try checking out the "Jenkins GitHub Pull Request Builder" plugin. It allows Jenkins to build pull requests automatically based on specific GitHub events.