Triggering Jenkins to run application tests when GitHub PR is created

553 views Asked by At

I am a noob to Jenkins, and I have a Jenkins server that runs an ansible playbook to deploy the app.

I would like to be able to have Jenkins run an ansible playbook which runs application python tests when a GitHub pull request is opened. I would then like the results of the tests to be displayed in the Github repo similar to how Travis does it. Are there any way to achieve this with Jenkins? Thanks

1

There are 1 answers

0
Martin On BEST ANSWER

This is achievable with Jenkins. There are 3 main steps to this task:

  1. Use the Jenkins GitHub plugin to trigger a build.
  2. Use the Jenkins Ansible plugin to execute your ansible playbook during build process.
  3. Update GitHub repo with the result. This part is a little more complex since I do not believe there is a Jenkins plugin for it. This can be done by adding a post-build task to your Jenkins build that consists of a script using the GitHub's API to update the repo with your result at your preference.

In the case Jenkins GitHub plugin does not allow trigger on pull request webhooks, you would have to implement your own listening of GitHub's webhooks API pull_request event and then launch Jenkins build remotely via URL.