2
votes

Given a Jenkins multibranch pipeline job that uses a property strategy to "suppress automatic SCM triggering" for all branches but 'default', how do you allow Jenkins to wait until night (say 7pm-6am) to build every other branch?

We used to be able to set the Poll SCM strategy for each job individually, which worked well.

Pipeline scripts allow you to set a pollSCM pipeline trigger property. However it won't get set unless the job has run at least once and there seems to be a defect where jobs are continuously triggered by scm changes, making it less useful.

1

1 Answers

1
votes

Jenkinsfile properties can (now) configure polling triggers and override the default triggering behaviour. This example enables daily builds for everything except 'default' and release branches (which are always built)

def alwaysBuild = (env.BRANCH_NAME == "default" || env.BRANCH_NAME ==~ /release-.*/);
properties([
    overrideIndexTriggers(alwaysBuild), 
    pipelineTriggers([pollSCM('@daily')])
]);  

NOTE: As of 2016-Sept, there seems to be a bug where pollSCM triggers multiple builds per change. Possibly this bug: https://issues.jenkins-ci.org/browse/JENKINS-38443