We are using the pipeline plugin with multibranch configuration for our CD. We have checked in the Jenkinsfile which works off git.
git url: "$url",credentialsId:'$credentials'
The job works fine, but does not auto trigger when a change is pushed to github. I have set up the GIT web hooks correctly.
Interestingly, when I go into a branch of the multibranch job and I click "View Configuration", I see that the "Build when a change is pushed to Github" is unchecked. There is no way to check it since I can not modify the configuration of the job (since it takes from parent) and the same option is not there in parent.
Any ideas how to fix this?
}
For declarative pipelines try:
For me this enables the checkbox "GitHub hook trigger for GITScm polling", but polling is not actually required. This requires the GitHub plugin.
For declarative pipelines, try this:
Resorting to polling adds latency - time that it takes for a build to start and hence finish giving back a result.
It seemed to me that the basic plugins have a low level of abstraction, so I switched to the Github Organization Folder plugin, which depends on all of them and sets up an organization hook for triggering builds branches and/or pull requests.
I found a way to check the checkbox "Build when a change is pushed to Github".
This line did the trick:
I think the polling is needed to make it work. Would be nice if no polling is needed.
Here's a
Jenkinsfile
example with this implemented:If you use Stash for example you can register a Post-Receive WebHook where you have to insert your URL form Jenkins like : http://jenkinsHost:9090/git/notifyCommit?url=ssh://git@gitHost:1234/test.git
In your jenkins Job you have to set at least the Build trigger "Poll SCM". And set a polling time of e.g 5 mins. This enables also the automatic branch indexing for your multibranch project configuration.