I'm trying to setup triggering a jenkins multibranch pipeline from Atlassian Stash using the stash webhook to jenkins plugin. My project config has Build Periodically set to @daily, Periodically if not otherwise set to 1 day and I have indexed my branches however when I click on the 'Trigger Jenkins' button on the stash webhook config I get the following error
Error: Jenkins response: No git jobs using repository
I have previously read that this could be because polling is disabled on the project however there is no setting to enable it in the top level. I have tried enabling it in the master branch Jenkinsfile however it did not show up as checked when I 'View Configuration' for the master job. I can also see in the Jenkins logs:
no trigger, or post-commit hooks disabled, on my-repo » master
I can't find any other way to get this working?
Step 1: go to your GitHub repository and click on 'Settings'. Step 2: Click on Webhooks and then click on 'Add webhook'. Step 3: In the 'Payload URL' field, paste your Jenkins environment URL. At the end of this URL add /github-webhook/.
Configuring Git with Jenkins Now open your project and go to configure. Step 2: Give the repository Url in Source Code Management, repository Url can be fetched by clicking on clone and download option of Github and you have to select the SSH Url. Also, add credentials there of Jenkins.
The hint from Jenkins log you see is correct
no trigger, or post-commit hooks disabled, on my-repo » master
The post-commit hook on Jenkins side is disabled by default after job is created without explicitly turning it on. To enable it you should update Build Triggers
configuration of the job that you want to be triggered (my-repo » master
in your case) by selecting the following two triggers:
[✓]
Build when a change is pushed to BitBucket
[✓]
Poll SCM (leave the Schedule text box empty)If you use Jenkins pipeline script instead of Jenkins UI then your Jenkinsfile
should contain proper triggers
directive (corresponding to the above screen):
triggers {
bitbucketPush()
pollSCM('') // empty cron expression string
}
The important thing is leaving Schedule field text box empty. Otherwise, if you enter cron expression there then your build will be triggered twice. Once on commit-hook notification and the second one when cron expression trigger gets fired. It's explained by the label placed under the Schedule field:
No schedules so will only run due to SCM changes if triggered by a post-commit hook
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