Friday, February 8, 2019

How to configure webhooks in Bitbucket to trigger a build in Jenkins? How to trigger automated builds in Jenkins through Bitbucket?

Webhooks are triggers that enables developers to trigger Jenkins jobs automatically every time there is a code change

Jenkins does automated builds in two ways:

1. pull - using poll scm
2. push mechanism - by triggering a build from Bitbucket or GitHub for every repository changes.

we will see in this article how to trigger a(push) build for every change in bitbucket repository:





Changes needed in Jenkins


1.Click on Manage Jenkins.  
2.Click on Configure Global Security.
3.Uncheck the option for Prevent Cross Site Request Forgery exploits
4.In matrix-based security change:

for Anonymous user, do the below:

Overall - Read  
Job - Build 
Job - Read  
Job - Workspace



 
 
 
 
Select the job you would like to configure webhook is for. Choose configure 
Also you need to have token created for the job you would like to trigger. 
Click on the build job. Go to triggers section and click 
on 
 Authentication Token field.














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 build/?token=myToken
 example the url should be like this - http://jenkins_server_url/job/myFreeStyleJob/build?token=myToken
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

How to Configure GitHub Advanced Security for Azure DevOps | How to Perform Security scan for Azure Repos using GitHub Advanced Security

GitHub Advanced Security for Azure DevOps brings the  secret scanning, dependency scanning  and  CodeQL code scanning  solutions already ava...