Giter Site home page Giter Site logo

zxdev158 / environment-variable-page-decoration-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jenkinsci/environment-variable-page-decoration-plugin

0.0 0.0 0.0 145 KB

Jenkins plugin to inject environment variables via the PageDecorator API

License: MIT License

Groovy 87.84% Dockerfile 12.16%

environment-variable-page-decoration-plugin's Introduction

Jenkins Environment Variable Page Decoration Plugin

https://wiki.jenkins.io/display/JENKINS/Environment+Variable+Page+Decoration+Plugin

Pretty much what it says on the tin. Use API exposed by PageDecorator to inject environent variables into Jenkins Pages. Primarily useful for adding deploy data to the footer.

This is targetted at systems that are deployed via some automated means, there is no UI for configuration.

Usage

You can set the following environment variables:

  • JENKINS_FOOTER_EXTRA - Add content to the footer after the Jenkins version content.
  • JENKINS_FOOTER_EXTRA_B64 - If this is set, then JENKINS_FOOTER_EXTRA is base64 decoded.
  • JENKINS_HEADER_EXTRA - Add content in the page head tags (e.g., css or javascript tags).
  • JENKINS_HEADER_EXTRA_B64 - If this is set, then JENKINS_HEADER_EXTRA is base64 decoded.

Example

This would be handled by your deploy tooling, but for the sake of a walkthrough (and something you can run locally with docker) you can set some environment variables:

export DEPLOY_TIME=$(date)
export DEPLOY_USER=${USER}
export GIT_BRANCH=$(git branch | grep \* | cut -d ' ' -f2)
export GIT_SHA=$(git rev-parse --short HEAD)

Create a footer template to consume the environment variables (data.sh):

echo "<span style='margin-left: 1em;'>deployed ${GIT_BRANCH}@${GIT_SHA} by ${DEPLOY_USER} at ${DEPLOY_TIME}</span>"

Create a base64 encoded string:

bash data.sh | base64 | pbcopy

Set the environment variables when running Jenkins (e.g., via Docker):

-e JENKINS_FOOTER_EXTRA="PHNwYW4gc3R5bGU9J21hcmdpbi1sZWZ0OiAxZW07Jz5kZXBsb3llZCBldnBkLXRlc3RAYWJjMTIzIGJ5IHR2b24gYXQgVGh1IE1heSAgMiAyMjozNzo1OSBFRFQgMjAxOTwvc3Bhbj4K" -e JENKINS_FOOTER_EXTRA_B64=1

environment-variable-page-decoration-plugin's People

Contributors

darxriggs avatar tvon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.