Skip to content

Instantly share code, notes, and snippets.

@ivan-pinatti
Created May 21, 2018 14:24
Show Gist options
  • Save ivan-pinatti/4c546abbf98bb91d1af3c773adb195ce to your computer and use it in GitHub Desktop.
Save ivan-pinatti/4c546abbf98bb91d1af3c773adb195ce to your computer and use it in GitHub Desktop.
Jenkins - Set Jenkins system message via groovy script - #jenkins #groovy #system #message
#!groovy
// imports
import jenkins.model.Jenkins
// parameters
def systemMessage = "Insert your Jenkins system message here."
// get Jenkins instance
Jenkins jenkins = Jenkins.getInstance()
// set Jenkins system message
jenkins.setSystemMessage(systemMessage)
// save current Jenkins state to disk
jenkins.save()
@RakeshNagarajan
Copy link

Thanks for your scrip. Is there any possible way like, the system message should revert back after restart of jenkins.

I am planning to set the outage message in the jenkins, after restart the message need to vanish.

@ivan-pinatti
Copy link
Author

Hi @RakeshNagarajan,

I don't think it is possible to revert, however, you can add a version of this script on your Post-Initialization Jenkins folder, which will change the system message when the Jenkins is started again.

Please check this link; https://wiki.jenkins.io/display/JENKINS/Post-initialization+script.

Thanks for your scrip. Is there any possible way like, the system message should revert back after restart of jenkins.

I am planning to set the outage message in the jenkins, after restart the message need to vanish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment