Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git stash, jenkins pipeline, No git jobs using repository

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?

like image 546
shmish111 Avatar asked Dec 13 '16 12:12

shmish111


People also ask

How do I link my Git repository to Jenkins?

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/.

How can you clone a Git repository via Jenkins?

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.


1 Answers

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:

  1. [✓] Build when a change is pushed to BitBucket
  2. [✓] Poll SCM (leave the Schedule text box empty)

enter image description here

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

like image 91
Marcin Kłopotek Avatar answered Nov 15 '22 03:11

Marcin Kłopotek