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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

ishan jain
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 ?

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/771929da-459f-4d6b-a224-edf5327e26dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Joshua Noble
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)

On Tuesday, September 12, 2017 at 10:56:32 AM UTC-4, ishan jain wrote:
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 ?

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/60de6c4e-966d-44b7-9039-d44d2481b558%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Robert Hales
In reply to this post by ishan jain
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. 

On Tuesday, September 12, 2017 at 8:56:32 AM UTC-6, ishan jain wrote:
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 ?

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/8d7b71dc-67d1-4a19-936c-ac5bce5d8b9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

ishan jain
This is exactly what i was looking for. Thanks.

On Friday, 22 September 2017 05:57:04 UTC+2, Robert Hales wrote:
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. 

On Tuesday, September 12, 2017 at 8:56:32 AM UTC-6, ishan jain wrote:
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 ?

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f04c2601-e8ee-4fbe-973b-12693c6955e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.