Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable automatic build from scm change in Jenkinsfile

I have a Jenkinsfile that I've set up with a cron for a pipelineTriggers parameter. I can't seem to figure out how to disable the job from building from a merge to the master branch of the repo. Is there a way in the Jenkinsfile to disable the automatic build from an scm change?

like image 443
numb3rs1x Avatar asked Mar 14 '17 22:03

numb3rs1x


2 Answers

If you're using a Multibranch Pipeline, you should be able to do this on the job's Configure page:

  1. Scroll down to "Branch Sources"
  2. Under "Property strategy", choose "Named branches get different properties"
  3. Click "Add exception", enter "master" as the branch name
  4. Click "Add property", choose "Suppress automatic SCM triggering"
  5. Save

That would prevent changes to the master branch from triggering a build of the corresponding job.

like image 67
Christopher Orr Avatar answered Sep 19 '22 15:09

Christopher Orr


For declarative pipelines, use the when directive with a triggeredBy condition, e.g.

when { triggeredBy 'TimerTrigger' } 
like image 38
flup Avatar answered Sep 19 '22 15:09

flup