Jenkins jobs can be triggered many ways. Here are those ways:
1. pull - using poll scm
2. Webhooks (push mechanism) - by triggering a build from Bitbucket or GitHub for every repository changes.
3. through slack channel. We will cover this in a later class.
Webhooks are triggers that enables developers to trigger Jenkins jobs automatically every time there is a code change
we will see in this article how to trigger a(push) build for every change in bitbucket repository:
Changes needed in Jenkins
1. Install the Bitbucket Plugin:
Go tom Manage Jenkins---Plugin Manager
Search Bitbucket and install without restart
Select the job you would like to configure webhook is for.
Choose configure
Click on the build job.
Go to triggers section and click on Build When a change is Pushed to Bitbucket
Also uncheck poll SCM option(if it was selected earlier)
Changes in Bitbucket
1. go to bitbucket, choose the repository, go to settings, click on web hooks.
2. enter title, url which is your jenkins job url - append b
example the url should be like this - http://jenkins_public_dns_server_url:8080/bitbucket-hook/
Sample url is given below:
http://jenkins_url:8080/bitbucket-hook/
3. status should be active
4. click on skip certificate verification
5. triggers --> repository push
Now make a code change in bitbucket to see if that triggers a build in Jenkins automatically.
No comments:
Post a Comment