Jenkins2 pileline poll scm

1,001 views
Skip to first unread message

Limor Shemesh

unread,
Mar 3, 2017, 10:12:41 AM3/3/17
to Jenkins Users
Hi
I upgraded Jenkins to 2.4 and started migrate jobs to pipeline jobs.
I have created JenkinsFile and configure the job to search it in github repo.
The job works great but I cannot find the way to add poll scm.
I want that the job will run on every push of the repo (master branch).
Please help.
Thanks. 

Michael Pailloncy

unread,
Mar 3, 2017, 11:05:12 AM3/3/17
to jenkins...@googlegroups.com
In the "Build Triggers" part inside your job configuration, you should have a "Periodically if not otherwise run" property.

However, if you're able to configure webhooks on your SCM side to notify your master about new commits/branches and PR, it's a better approach : https://www.cloudbees.com/blog/polling-must-die-triggering-jenkins-builds-git-hook 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/60ee6556-433b-4718-9589-d6310fdf4a13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

shli...@gmail.com

unread,
Mar 5, 2017, 3:42:29 AM3/5/17
to Jenkins Users
I cannot find the "Periodically if not otherwise run" under "Build Triggers".
Which plugin do I need to install to enable this option?


On Friday, March 3, 2017 at 6:05:12 PM UTC+2, mpapo - Michael Pailloncy wrote:
In the "Build Triggers" part inside your job configuration, you should have a "Periodically if not otherwise run" property.

However, if you're able to configure webhooks on your SCM side to notify your master about new commits/branches and PR, it's a better approach : https://www.cloudbees.com/blog/polling-must-die-triggering-jenkins-builds-git-hook 
2017-03-03 16:12 GMT+01:00 Limor Shemesh <li...@gigaspaces.com>:
Hi
I upgraded Jenkins to 2.4 and started migrate jobs to pipeline jobs.
I have created JenkinsFile and configure the job to search it in github repo.
The job works great but I cannot find the way to add poll scm.
I want that the job will run on every push of the repo (master branch).
Please help.
Thanks. 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

Michael Pailloncy

unread,
Mar 5, 2017, 4:24:17 AM3/5/17
to jenkins...@googlegroups.com
What's your job type (Pipeline, MultiBranch, etc) ?

If you have created a MultiBranch/Bitbucket Team/Project or GitHub Organization job type, you should have this property in the job configuration.
If your job is a simple Pipeline, you should have a "Poll SCM" property inside "Build Triggers" part of the configuration.

As far as I know, you don't need any extra plugin to enable this.



To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/8b82d24f-130d-44d9-a358-b292ef36840e%40googlegroups.com.

Bill Dennis

unread,
Mar 5, 2017, 9:40:05 AM3/5/17
to Jenkins Users
If your Jenkinsfile is in the same repo, using declarative pipeline you can have triggers in the pipeline to do this:

pipeline {
triggers {
pollSCM('*/5 * * * *')
}
...
}

It works for me using subversion.

Bill

GS_L

unread,
Mar 6, 2017, 5:15:25 AM3/6/17
to Jenkins Users
Hi
The triggers - pollscm doesn't work on the checkout step.
I want that the pollscm will trigger a build in every push in - checkout([$class: 'GitSCM', branches: [[name: '*/master']], ...
This didn't work for me:

pipeline {
triggers {
pollSCM('*/5 * * * *')
}
    agent { label 'web-ui-04888827' }

stages {


stage('Build') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'cloudify-stage']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '5006a20b-84d4-4681-ae49-886247acd47b', url: 'https://github.com/cloudify-cosmo/cloudify-stage.git']]])
dir('cloudify-stage') {
sh '''sudo npm install
sudo npm install webpack -g
sudo npm install bower -g
sudo npm install gulp -g
sudo npm install grunt-cli -g
bower install'''
dir('semantic') {
sh 'gulp build'
}
sh 'grunt build'
dir('backend') {
sh 'npm install'
}
sh 'webpack --config webpack.config-prod.js --bail'
sh 'sudo chown jenkins:jenkins -R .'
}
}
}

jer...@bodycad.com

unread,
Mar 6, 2017, 8:48:59 AM3/6/17
to Jenkins Users
You can set your pipeline project configure like the following:

Build Triggers

This will consider the pipeline scripts checkout and the checkout done into the pipeline. The later need at least a single run manually started to register the code checkout with the first execution of the jenkinsfile. I haven't tested this with multi branch.
Reply all
Reply to author
Forward
0 new messages