How to set global quiet period automatically on Jenkins startup

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

How to set global quiet period automatically on Jenkins startup

Barry Laffoy
In my never-ending quest to create a deployment script for Jenkins (why is this so difficult?), I would like to be able to configure the quiet period on startup, without needing to configure it through the UI.

Is there a way of configuring this through groovy? Ideally I would like to place a script in my init.groovy.d/ so that it will be triggered automatically.

In the class files, I found jenkins.model.GlobalQuietPeriodConfiguration, but this only exposes a method to get the quiet period

gqpc = new jenkins.model.GlobalQuietPeriodConfiguration()
gqpc.getQuietPeriod()

Result: 5

There is a method boolean configure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject json), but this appears to be designed solely to be called from the UI.

Is there some standard pattern by which I could construct a dummy StaplerRequest so I can run configuration in my groovy script?

Alternatively, is there some other public method I could or should be using?

Thanks.

--
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/5fac40cf-3469-4819-b9da-44e19d93b630%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to set global quiet period automatically on Jenkins startup

Barry Laffoy
By digging into the source code, I found an answer myself.

import jenkins.model.Jenkins
instance
= Jenkins.getInstance()
instance
.setQuietPeriod(0)

As always, I'm left to wonder if this is how it's supposed to be done, or have I just completely misunderstood Jenkins?

On Wednesday, 8 February 2017 09:18:46 UTC, Barry Laffoy wrote:
In my never-ending quest to create a deployment script for Jenkins (why is this so difficult?), I would like to be able to configure the quiet period on startup, without needing to configure it through the UI.

Is there a way of configuring this through groovy? Ideally I would like to place a script in my init.groovy.d/ so that it will be triggered automatically.

In the class files, I found jenkins.model.GlobalQuietPeriodConfiguration, but this only exposes a method to get the quiet period

gqpc = new jenkins.model.GlobalQuietPeriodConfiguration()
gqpc.getQuietPeriod()

Result: 5

There is a method boolean configure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject json), but this appears to be designed solely to be called from the UI.

Is there some standard pattern by which I could construct a dummy StaplerRequest so I can run configuration in my groovy script?

Alternatively, is there some other public method I could or should be using?

Thanks.

--
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/4ca46cfa-8251-41cf-bcf6-e04856fd9fef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to set global quiet period automatically on Jenkins startup

Brandon Fryslie
I just wanted to respond.  I have automated pretty much everything related to Jenkins lately, and looking through the source code and then using that to write a groovy script is exactly how it is supposed to be done.  Jenkins was never designed to be automated (which is strange considering it is an automation tool), so using the source code to write groovy scripts is pretty much the only workable technique.  

On Wednesday, February 8, 2017 at 2:32:37 AM UTC-7, Barry Laffoy wrote:
By digging into the source code, I found an answer myself.

import jenkins.model.Jenkins
instance
= Jenkins.getInstance()
instance
.setQuietPeriod(0)

As always, I'm left to wonder if this is how it's supposed to be done, or have I just completely misunderstood Jenkins?

On Wednesday, 8 February 2017 09:18:46 UTC, Barry Laffoy wrote:
In my never-ending quest to create a deployment script for Jenkins (why is this so difficult?), I would like to be able to configure the quiet period on startup, without needing to configure it through the UI.

Is there a way of configuring this through groovy? Ideally I would like to place a script in my init.groovy.d/ so that it will be triggered automatically.

In the class files, I found jenkins.model.GlobalQuietPeriodConfiguration, but this only exposes a method to get the quiet period

gqpc = new jenkins.model.GlobalQuietPeriodConfiguration()
gqpc.getQuietPeriod()

Result: 5

There is a method boolean configure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject json), but this appears to be designed solely to be called from the UI.

Is there some standard pattern by which I could construct a dummy StaplerRequest so I can run configuration in my groovy script?

Alternatively, is there some other public method I could or should be using?

Thanks.

--
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/28ff01c4-fe6f-471f-9fc7-36105a1ff661%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to set global quiet period automatically on Jenkins startup

Barry Laffoy
Hi Brandon

I really appreciate your response. It's good to know that I'm not the only person that feels this pain.

It's frustrating that a tool that's so central to the world of automation seems actively hostile to being automated itself. Both the design of the tool and the culture surrounding it seem inimical to the idea that a Jenkins deployment should or could be fully automated.

Oh well, complaining won't make it any better. :-(

On Fri, Jul 14, 2017 at 7:24 PM, Brandon Fryslie <[hidden email]> wrote:
I just wanted to respond.  I have automated pretty much everything related to Jenkins lately, and looking through the source code and then using that to write a groovy script is exactly how it is supposed to be done.  Jenkins was never designed to be automated (which is strange considering it is an automation tool), so using the source code to write groovy scripts is pretty much the only workable technique.  

On Wednesday, February 8, 2017 at 2:32:37 AM UTC-7, Barry Laffoy wrote:
By digging into the source code, I found an answer myself.

import jenkins.model.Jenkins
instance
= Jenkins.getInstance()
instance
.setQuietPeriod(0)

As always, I'm left to wonder if this is how it's supposed to be done, or have I just completely misunderstood Jenkins?

On Wednesday, 8 February 2017 09:18:46 UTC, Barry Laffoy wrote:
In my never-ending quest to create a deployment script for Jenkins (why is this so difficult?), I would like to be able to configure the quiet period on startup, without needing to configure it through the UI.

Is there a way of configuring this through groovy? Ideally I would like to place a script in my init.groovy.d/ so that it will be triggered automatically.

In the class files, I found jenkins.model.GlobalQuietPeriodConfiguration, but this only exposes a method to get the quiet period

gqpc = new jenkins.model.GlobalQuietPeriodConfiguration()
gqpc.getQuietPeriod()

Result: 5

There is a method boolean configure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject json), but this appears to be designed solely to be called from the UI.

Is there some standard pattern by which I could construct a dummy StaplerRequest so I can run configuration in my groovy script?

Alternatively, is there some other public method I could or should be using?

Thanks.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/TUFSoOIROaE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/28ff01c4-fe6f-471f-9fc7-36105a1ff661%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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/CAO94mS2OyqwzA8PifoAhZwWjk3X_%3D21arb47sWnG3p4KfjPJzw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...