1

We use CloudBees-2.138.2.2 Jenkins and have had lot of challenges to trigger jenkins jobs only based on commits in our Github repo. I am still looking for the exact working script for scripted pipeline and not declarative one.

so For example :- pipelineTriggers([cron('0-59/2 * * * *')]), works but pipelineTriggers([pollSCM('0-59/2 * * * *')]), never works despite new commits

Ashley
  • 1,447
  • 3
  • 26
  • 52
  • Did you consider such option as using 'Pipeline script from SCM' (via Jenkinsfile) with 'GitHub hook trigger for GITScm polling' enabled? E.g., see [this](https://dzone.com/articles/adding-a-github-webhook-in-your-jenkins-pipeline) example. It's a standard way of configuration and much easier to configure. – biruk1230 Jan 03 '19 at 16:09
  • Thanks for the response. I am aware of that but we want to establish entire pipeline using a single Jenkinsfile that uses scripted pipeline syntax. Hence the ask. – Ashley Jan 03 '19 at 16:55

2 Answers2

1

was able to make it work using :-

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

This way the job polls the repo every minute and will trigger build only when it detects a new commit.

Ashley
  • 1,447
  • 3
  • 26
  • 52
1

You can try adding the following in your scripted pipeline

properties([pipelineTriggers([githubPush()])])
Nicodemuz
  • 3,539
  • 2
  • 26
  • 32