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
Best How To :
This is achievable with Jenkins. There are 3 main steps to this task:
- Use the Jenkins GitHub plugin to trigger a build.
- Use the Jenkins Ansible plugin to execute your ansible playbook during build process.
- 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.