I have successfully setup a webhook trigger in bitbucket for a Jenkins freestyle project, for test purposes.
Unfortunately my Jenkins project is using the Pipeline format, and I am unable to get Bitbucket to trigger that kind of project; the problem seems to be that there is no Jenkins project registered to pull from the repo that the Bitbucket webhook is coming from, and Jenkins replies with:
Error: Jenkins response: No git jobs using repository: ssh://git@myhost:7999/xxx/testing-jenkins.git and branches: master No Git consumers using SCM API plugin for: ssh://git@myhost:7999/xxx/testing-jenkins.git
The pipeline project is setup in a way that the Jenkinsfile
is to be found in the given repository (ssh://git@myhost:7999/xxx/testing-jenkins.git
), by using the "Pipeline script from SCM" option.
Therefore there is actually a kind of "git consumer" for the Pipeline, but this does not seem to be taken into account by Jenkins, probably because this is not a real project source, but a pipeline source.
Are there any examples of integration of Bitbucket and Jenkins Pipeline projects? I have been unable to find any.
Run pipelines steps manuallyConfigure a manual step by adding trigger: manual to the step in your bitbucket-pipelines. yml file. Since a pipeline is triggered on a commit, you can't make the first step manual. If you'd like a pipeline to only run manually, you can set up a custom pipeline instead.
If your are looking for a full Bitbucket and Jenkins Pipeline, I highly recommend to use the Bitbucket Branch Source Plugin. The plugin will discover all Branches and Pull Requests and build all who have a JenkinsFile in the root of repo.
You can also use create a project as Bitbucket Team, who will scan all repo of your organization:
See the official doc of CloudBees
I was struggling with the same problem. Following are the key points I followed.
In Jenkins pipeline job,
In BitBucket repository,
Go to Settings > Services
Select 'Jenkins' from the drop down and 'Add service'.
Check 'Csrf Enabled'
Endpoint : http://username:[email protected]/
You can find username and apitoken at Jenkins home > People Select the user and click on configure. Under 'API Token' click on the 'Show API Token' button and you see the username and apitoken
Module name : This is optional. It can be any particular file or folder which is to be watched.
Project name : The project name in Jenkins.
If the job is in some folder structure, say I have 'MyTestFolder/MyTestPipelineJob', Project name to be mentioned is 'MyTestFolder/job/MyTestPipelineJob'
Token : 'Authentication Token' created in Jenkins job.
You are ready to go!!
I referred http://felixleong.com/blog/2012/02/hooking-bitbucket-up-with-jenkins/ and some of my instincts. :)
A simple solution is to use Generic Webhook Trigger Plugin in Jenkins.
You would need to
JENKINS_URL/generic-webhook-trigger/invoke?token=whatever_you_picked
The plugin will give you clear feedback when it is invoked so that troubleshooting is made easy.
It is up to you to pick whatever values you need from the webhook in order to clone the correct repository or whatever it is you want to do when the it is invoked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With