How to enable SCM polling with the Jenkins Pipeline plugin
This is a question related to How to make SCM polling work with the Jenkins Workflow plugin. That thread answers how to use SCM polling in a pipeline script once SCM polling is enabled but does not cover how to enable SCM polling.
For example, if you wanted to use the mulit-branch pipeline plugin to create jobs automatically using a Jenkinsfile there is not a way I know of to have the “Poll SCM” option enabled in the job. This makes it difficult to provision on-demand environments such as creating a docker container that has the jobs setup from the beginning. Because you would have to sign-in to Jenkins and go to the configuration and select the “Poll SCM” option once the container was started. Cloudbees offers a template plugin to help solve this problem.
However this is not available to Jenkins using the free version. Is there any workaround or solution for users on the free version of Jenkins?
3 Solutions collect form web for “How to enable SCM polling with the Jenkins Pipeline plugin”
if you wanted to use the multi-branch pipeline plugin to create jobs automatically using a Jenkinsfile there is not a way I know of to have the “Poll SCM” option enabled in the job
Nor is any needed. Multibranch projects have a configurable polling interval for the branch indexing as a whole, which also serves as a per-branch build trigger, and will also receive webhooks automatically.
I am thinking about the same problem.
If you are using a online Git service like
Bitbucket, I think you could use their
Webhooks features to solve it. I have not been able to test the solution yet, but it should work.
Multibranch Pipeline configuration, enable the
Trigger builds remotely option.
Then you need to enable your Github/Bitbucket Webhook on your repository, using the path (as described in the Jenkins configuration descrition):
To answer the question how to enable SCM polling, you need to do the following.
Using the Pipeline Syntax generator and “properties: Set job properties” you can generate the following which will enable SCM polling.
However as Jesse Glick points out for Multibranch pipelines you don’t need to enable SCM polling.