Best way to reload job settings from Jenkinsfile without triggering a build

3,307 views
Skip to first unread message

ishan jain

unread,
Sep 12, 2017, 10:56:32 AM9/12/17
to Jenkins Users
Hi all,

I keep my Jenkinsfile in a git repo. For features and fixes, i create branches on this repo, each having a slightly different Jenkinsfile. I have a jenkins job of type multibranch pipeline, scanning these pipelines as i create a branch.

Assuming i have the basic declarative pipeline structure for all Jenkinsfiles in different branches

pipeline {
    agent any
    triggers
{
        cron
('H 4/* 0 0 1-5')
   
}
    stages
{
        stage
('Example') {
            steps
{
                echo
'Hello World'
           
}
       
}
   
}
}


I sometimes want to change the cron of certain jobs, sometimes even to disable it. The best ideal way to do it would be to change it in Jenkinsfile in the GIT repo. But after changing the code and invoking 'scan multibranch pipeline' from Jenkins UI, it does 1 execution, which is something i do not want.

How can i make sure that updated settings done in Jenkinsfile are picked up without executing it ? And can it happen automatically immediately ?
What is the simplest way to disable a job for a while in the above setup ?

Joshua Noble

unread,
Sep 12, 2017, 12:47:35 PM9/12/17
to Jenkins Users
The challenge here is that a multibranch pipeline uses source control events, by design, to launch itself. Since the Jenkinsfile (your config) is stored in source control, there's really no way to push without triggering a run. As soon as you disable and/or delete the job, it will be re-created and run after you push to your repo. (At least it will using the Github branch source plugin, which uses multibranch config setups under the hood)

Robert Hales

unread,
Sep 21, 2017, 11:57:04 PM9/21/17
to Jenkins Users
In your Branch Sources section of your Multibranch job, you just have to add the "Suppress Automatic SCM Triggering". This will prevent the branch indexing scan from kicking off a new build when it finds changes. 

ishan jain

unread,
Sep 22, 2017, 4:31:17 AM9/22/17
to Jenkins Users
This is exactly what i was looking for. Thanks.
Reply all
Reply to author
Forward
0 new messages