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.

  • DropWizard app cannot be accessed from outside Docker
  • Jboss 5.1 in Dockerfile - how to reach the server in a browser
  • Docker-compose start fail
  • Rake task seems not to write files in a Docker container
  • Bamboo: docker task “An error occurred trying to connect: Post http://127.0.0.1:2375/v1.22/build”
  • How to use command in docker-compose.yml
  • 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?

  • Restore mongodb dump from a folder using Docker in ubuntu
  • How to prevent binding to docker0 bridge in overlay mode
  • Docker running ubuntu with elasticsearch
  • Docker: effect of logging driver on logs
  • Flocker: How do I provide a custom /etc/mongodb.conf file?
  • How to access GIT repo with my private key from Dockerfile
  • 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 Github or 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.

    In your 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): JENKINS_URL/job/test/build?token=TOKEN_NAME

    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.

    properties([pipelineTriggers([pollSCM('')])])
    

    However as Jesse Glick points out for Multibranch pipelines you don’t need to enable SCM polling.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.