Code Monkey home page Code Monkey logo

pipeline-keepenv-step-plugin's Introduction

Pipeline: Keep Environment Step Plugin

Introduction

This plugin contributes the keepEnv step for Jenkins Pipelines. It is similar to the withEnv step, but only retains environment variables that are defined in the argument, or are "system" environment variables.

It is similar in function to the "Keep Only Specified Environment Variables" option for some build steps introduced in Jenkins 2.248.

Getting started

The following Pipeline demonstrates how this plugin works:

node {
    withEnv(['foo=bar', 'baz=qux', 'PATH=/usr/bin:/bin:/foo']) {
        sh 'env'
        keepEnv(['foo', 'WORKSPACE']) {
            sh 'env'
        }
    }
}
  • The second invocation of env will not list baz or most Jenkins-contributed environment variables, like BUILD_ID or NODE_NAME.

  • The variables foo (from the surrounding withEnv block), WORKSPACE (contributed by Jenkins), a few essential Jenkins-contributed variables, as well as system-contributed variables (like PATH) will still be available.

  • System-contributed environment variables that are not set to be kept will be reset to their default value (PATH in the example) instead of being undefined.

Issues

Report issues and enhancements in the Jenkins issue tracker.

Contributing

LICENSE

Licensed under MIT, see LICENSE

pipeline-keepenv-step-plugin's People

Contributors

daniel-beck avatar notmyfault avatar

Watchers

 avatar  avatar  avatar  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.