Search code examples
jenkinsheaderjenkins-plugins

Displaying announcement on all Jenkins pages


Is there a simple way or a plugin to display any custom message on Jenkins pages for all users? I wanted to display important changes or actions directly on Jenkins instead of emailing everyone. What I mean is to have configurable panel similar to "Jenkins is going to shut down" which I could display and possibly change color. I tried to find plugins for that but found nothing.


Solution

  • Ok, I'll answer my dummy question, maybe someone will look for it later.

    There's a plugin for injecting code to page header and footer: https://wiki.jenkins-ci.org/display/JENKINS/Page+Markup+Plugin It's not as easy to find as it should be downloaded from creators' page (link in description).

    Without an extra plugin: In my case it was simpler as it was enough to add system message (manage jenkins -> configure system -> system message). You can add CSS to Jenkins\war\css\style.css and use it in system message. I reused "shutdown-msg" which is displayed when jenkins is going to shut down.

    #shutdown-msg {
        font-weight: bold;
        color: white;
        background-color: #ef2929;
        text-align: center;
        margin-left: 2em;
        margin-right: 2em;
        margin-bottom: 0.5em;
        padding: 0.5em;
        -moz-border-radius: 0.5em;
    }
    
    #yellow-msg {
        font-weight: bold;
        color: black;
        background-color: #eded78;
        text-align: center;
        margin-left: 2em;
        margin-right: 2em;
        margin-bottom: 0.5em;
        padding: 0.5em;
        -moz-border-radius: 0.5em;
    }
    
    #green-msg {
        font-weight: bold;
        color: white;
        background-color: #34ba51;
        text-align: center;
        margin-left: 2em;
        margin-right: 2em;
        margin-bottom: 0.5em;
        padding: 0.5em;
        -moz-border-radius: 0.5em;
    }
    
    #blue-msg {
        font-weight: bold;
        color: white;
        background-color: #2d72d8;
        text-align: center;
        margin-left: 2em;
        margin-right: 2em;
        margin-bottom: 0.5em;
        padding: 0.5em;
        -moz-border-radius: 0.5em;
    }
    
    #grey-msg {
        font-weight: bold;
        color: white;
        background-color: #6b7777;
        text-align: center;
        margin-left: 2em;
        margin-right: 2em;
        margin-bottom: 0.5em;
        padding: 0.5em;
        -moz-border-radius: 0.5em;
    }
    <div id="shutdown-msg">Red message</div> 
    <div id="green-msg">Green message</div>
    <div id="yellow-msg">Yellow message</div>
    <div id="blue-msg">Blue message</div>
    <div id="grey-msg">Grey message</div>