Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

Skip to end of metadata
Go to start of metadata

Plugin Information

View Environment Injector on the plugin site for more information.

The current version of this plugin may not be safe to use. Please review the following warnings before use:

Older versions of this plugin may not be safe to use. Please review the following warnings before using an older version:

This plugin is up for adoption. Want to help improve this plugin? Click here to learn more!

This plugin makes it possible to have an isolated environment for your jobs.


EnvInject plugin provides the following features:

  • Removes inherited environment variables by the Jenkins Java process
  • Injects environment variables at node (master/slave) startup
  • Executes a setup script before or/and after a SCM checkout for a run
  • Injects environment variables before or/and after a SCM checkout for a run
  • Injects environment variables as a build step for a run
  • Injects password values for a run
  • Exports environment variables at the end of the build in order to to know the set of environment variables used for each build


This plugin has some known limitations. For Example, Pipeline Plugin is not fully supported. See the documentation below for more details.

Table of contents

Some use cases

  • To remove inherited environment variables (PATH, ANT_HOME, ...) at node level (master/slave), available by default for a job run.
  • To inject variables in the first step of the job (before the SCM checkout)
  • To inject variables based on user parameter values
  • To execute an initialization script before a SCM checkout.
  • To execute an initialization script after a SCM checkout
  • To inject variables as a build step obtained from a file filled in by a previous build step
  • To know environment variables used for a build
  • To inject build cause as environment variable for a build
  • To inject environment variables from the evaluation of a Groovy script (powered by Script Security Plugin)
  • To export environment variables as a metadata in your binary repository

Build Causes

This plugin also exposes the cause of the current build as an environment variable. A build can be triggered by multiple causes at the same time e.g. an SCM Change could have occurred at the same time as a user triggers the build manually.

The build cause is exposed as a comma separated list:


In addition, each cause is exposed as a single envvariable too:



At node (master and agent) level

At job level

Set up a clean environment

Inject variables after a SCM checkout

Inject variables as a build step

Variables Traceability

Each build captures environment variables and stores them in an environment file called 'injectedEnvVars.txt' located in

For an old build, you can display injected environment variables through the right UI menu on the build page.

You can also get build environment variables by the following HTTP GET URL: <jenkins_url>/job/<job_name>/<build_number>/injectedEnvVars/export
XML, JSON and TXT format are supported.
For example:

  • curl -X GET -H"Accept:text/plain" <jenkins_url>/job/<job_name>/lastBuild/injectedEnvVars/export
  • curl -X GET -H"Accept:application/xml" <jenkins_url>/job/<job_name>/18/injectedEnvVars/export
  • curl -X GET -H"Accept:application/json" <jenkins_url>/job/<job_name>/18/injectedEnvVars/export


Append to PATH on Windows


This screenshot is from an older version of EnvInject. Starting with EnvInject 1.93, any backslashes (such as Windows directory separators) in environment variables should be escaped (doubled). (See JENKINS-31573.)

Gerrit Trigger plugin with parameterized Build branch name

  • Check "This build is parameterized"
    • Default Value: master
  • Check "Prepare an environment for the run"
    • Evaluated Groovy script:

      if (!binding.variables.containsKey('GERRIT_REFSPEC')) {
          return [GERRIT_REFSPEC: "refs/heads/$GERRIT_BRANCH"]

Additional features provided by other plugins

Shared Objects plugin contributes to Envinject plugin that enables you to populate shared objects as environment variables.

Extensibility with other plugins

EnvInject captures build environment variables populated by plugins providing environment variables through Jenkins extension points (such as BuildWrappers, EnvironmentContributions and so on).
Environment variables injected by the EnvInject plugin are available in Jenkins triggers (for example in all XTrigger plugin typologies, injected environment variable can be used).
Injected environment variables with the EnvInject plugin are captured by the BuildContext capture plugin.

Comparison with other plugins

This plugin is an alternative to Setenv Plugin and Envfile Plugin plugins
Note 1: The EnvInject plugin automatically migrates the Jobs configuration from these plugins. The setenv and/or the envfile plugins can be deleted from your plugin list.
Note 2: Master and slave are managed.

Known incompatibilities

Jenkins Pipeline

Even though it is possible to set up the EnvInject Job Property and build step in Pipeline, the plugin does not provide full compatibility with Pipeline Plugin.

Supported use-cases:

  • Injection of EnvVars defined in the "Properties Content" field of the Job Property
    • These EnvVars are being injected to the script environment and will be inaccessible via the "env" Pipeline global variable
    • Please note there is also a known compatibility issue with Durable Task Plugin 1.13

All other use-cases of the plugin may work incorrectly in Jenkins Pipeline. Please see JENKINS-42614 for more information about unsupported use-cases. There is no short-term plan to fix the compatibility issues though any pull requests to the plugin will be appreciated.

Mask Passwords Plugin

MaskPasswords plugin is able to mask password elements. However, technically, this plugin provides its own class.

And we don't want to have a hard dependency from the EnvInject plugin to any other plugin. Therefore, EnvInject can't retrieve information from the MaskPassword plugin. However, EnvInject provides all MaskPasswords features. 

Tool Environment Plugin

EnvInject can't use exported environment variables provided by the Tool Environment plugin.
Instead, we suggest to use the SharedObjects Plugin. It covers Tool Env plugin features and provides a good integration with EnvInject.

Known limitations

  • As into regular shell scripts, you are not able to use "." character for environment variable names
  • Only previous environment variables are available for polling
    Some plugins provide polling mechanisms (such as SCM plugins, XTrigger plugins, ...) and you want to use injected environment variables in form fields of these plugins. Unfortunately, injected environment variables are processed only at build time therefore after the build is scheduled. Therefore, we can't access environment variables configured within the job. However, previous injected environment variables (from the previous build) are retrievable (implemented for example in the XTtrigger plugins). For the other plugins, authors are free to add the envinject-lib library dependency in their plugins in order to provide the ability to use environment variables given the EnvInject plugin.


Newer releases

See GitHub Releases

2.1.6 (Jul 07, 2018)

Release with minor improvements in the codebase:

  • (info) PR #131 - refactor the code to prevent warnings about attempts to (de-)serialize anonymous classes in Jenkins 2.107.2+
  • (info) PR #129 - update the plugin so that it can be tested with Plugin Compat Tester
  • (info) PR #130 - fix typo in the Groovy script variable documentation

2.1.5 (Oct 13, 2017)

  • Add compatibility notice for issues reported in 2.1.4

2.1.4 (Oct 07, 2017)


 There are two regression issues reported: JENKINS-47364JENKINS-47370

  • Variable substitution stopped work in some cases
  • It is a regression after the JENKINS-26583 patch
  • In particular, it affects Jenkins Pipeline which is not covered by autotests

The fix will be published soon. The plan is to make the newly introduced behavior opt-in

  • (error)JENKINS-26583 - The plugin does not longer override Environment Variables from plugins by the values persisted in its cache.
    • This update does not solve all potential conflicts between EnvInject and other environment-contributing plugins
  • (error)JENKINS-46479 - Prevent environment variables from being deleted on existing builds when the action is saved before cache initialization.
  • (info) Update EnvInject Lib from 1.26 to 1.27 in order to pick FindBugs fixes and JENKINS-46479.

2.1.3 (July 3, 2017)

  • (error)JENKINS-32428 - Fix glitches in JSON escaping in REST API (regression in 2.1.1)

2.1.2 (Jun 28, 2017)

2.1.1 (Jun 20, 2017)

  • (error) JENKINS-32428 - Escape XML and JSON outputs in REST API for "Injected Environment Variables"
  • (error) JENKINS-44263 - Prevent showing empty "Injected Environment Variables" list after build loading from the disk due (reliance on the cached value)

2.1 (May 12, 2017)

This is an API release, which is a preparation for a better Jenkins Pipeline support in the plugin (JENKINS-42614).

  • (plus) JENKINS-43845 - Create new EnvInject API plugin, which provides new Pipeline-compatible API of EnvInject Lib and EnvInject API util classes
  • (plus) JENKINS-43536 - Rework internal logic to avoid using AbstractProject explicitly where possible
  • (plus) JENKINS-43535 - Deprecate old API in EnvInject Lib and provide migration guidelines

Expected behavior changes:

  • AbstractProject types (Freestyle, Matrix, JobDSL, etc.) - nothing changes in the behavior
  • Jenkins Pipeline - some use-cases may start or stop working. Jenkins Pipeline stays untested (see Known Limitations)

2.0 (Apr 10th, 2017)

This is a security release of the plugin.

  • (error) SECURITY-256 - Arbitrary Groovy code execution vulnerability
  • (error) SECURITY-348 - Low privilege users are able to read parts of some files on master


This plugin release is not fully compatible with Previous EnvInject versions. A manual job configuration update may be required. See the referenced issues for more information.

1.93.1 (Sep 30th, 2016)

  • (plus) JENKINS-31829 - Add currentListener Groovy variable
  • (info) JENKINS-38607 - Jenkins Update Center now shows compatibility warnings when upgrading from versions below 1.93 (See the compatibility notice regarding JENKINS-31573)
  • (error) PR #109 - Incorrect initialization of the field in EnvInject build wrapper with Deprecated API. No user-visible impact
  • (info) PR #109 - Escape all plugin Jelly views by default
  • (info) PR #107 - Upgrade Jenkins Test Harness framework to the latest version, improve test coverage

1.93 (Sep 26th, 2016)

  • (info) Update to the new parent POM, 1.609.3 is a new target core version
  • (error) JENKINS-31573 - Incorrect parsing of newline characters
  • (error) JENKINS-30028 - Timestamper was displaying shifted timestamps due to the integration issue with EnvInject
  • (error) JENKINS-36545 - WORKSPACE variable was unavailable in Groovy script injector
  • (error) JENKINS-36466 - Update env-inject-lib to 1.24 in order to avoid potential incompatibilities on core versions with detached and deleted Matrix Project plugin
  • (error) JENKINS-32693 - Fix BuildCauseRetriever when a build has null cause action
  • (error) Cleanup issues reported by FindBugs: tolerance against node disconnection, etc.
  • (info) JENKINS-23274 - Do not output contents of the "Evaluated Groovy script" to console
  • (info) Document the current behavior of Node and Jenkins properties (JENKINS-23666)
  • (info) Improve diagnostics of issues during the environment setup in EnvInjectBuildWrapper (e.g. JENKINS-36237)
Compatibility notes:
  • Fix of JENKINS-31573
    • The change introduces a new property file parsing engine, which starts following the standard for backslashes
    • You may need to update the property files (e.g. convert backslash entries to double backslash)

1.92.1 (Aug 21th, 2015)

  • (error) JENKINS-27382 - EnvInjectPluginAction::buildEnvVars() injects masks instead of passwords to the environment (regression since 1.90)
    • There are many similar issues in JIRA, which have been probably fixed by the patch

1.92 (Aug 18th, 2015)

  • (plus) JENKINS-29817 - Contribute Job Property Contents to the project environment (polling, etc.)

  • (plus) JENKINS-29867 - Permissions engine + global option for disabling the Injected vars
  • (error) Fix several issues discovered by FindBugs

1.91.4 (Aug 4th, 2015)

1.91.3 (May 15th, 2015)

  • (error) Fix JENKINS-28409 - File descriptor leak in "Inject Passwords" build wrapper

  • (error) Fix JENKINS-28188 - StringIndexOutOfBoundsException when no root cause for the build

1.91.2 (Apr 14th, 2015)

  • (error) Fix JENKINS-27496 - NPE during submission of EnvInject JobProperty when the form is empty (regression, since 1.91)

1.91.1 (Mar 11th, 2015)

  • (error) Fix JENKINS-27342 - NPE in EnvInjectPluginAction.transformEntry() when there is no sensible variables (regression, since 1.91)

1.91 (Mar 8th, 2015)

* Fix JENKINS-19852 - NPE during submission of EnvInject JobProperty configurations w/o admin permissions
* Fix JENKINS-19222 - EnvInject undefines NODE_NAME environment variable on master
* Fix JENKINS-23447 - Mask sensitive data in injectedEnvVars.txt when displayed on UI or persisted on disk
* Fix JENKINS-24785 - BUILD_CAUSE is always UPSTREAMTRIGGER in multi-configuration jobs


There are showstopper bugs reported to this version. Please avoid the upgrade till the next release


* JENKINS-24130 - Added an option to mask PasswordParameters
* Execute Groovy scripts to inject environment variables in Build Wrappers
* Fix JENKINS-22126 - Override build parameters only when explicitly requested
* EnvInject escapes a sensitive data from other Environment contributors
* Fix JENKINS-22169 - Migration from Setenv Plugin overwrites existing envinject configurations


* Don't mask stacktraces on errors
* Upgrade to envinject-lib-1.19


* Fix JENKINS-16316 - Changes to global variables not honored
* Log both source and resolved unreachable properties file paths
* Fix JENKINS-14144 - use a WorkspaceListener to avoid injecting a temporary


* Actually load script from master


* Fix reopen JENKINS-13348 - EnvInject overriding WORKSPACE variable


* Retain line break characters in property values.


* Add logger to Groovy script evaluation


* Fix reopen JENKINS-16316 - Global variables not updated


* Fix JENKINS-16566 - poll SCM not work after upgrade the EnvInject Plugin to 1.81
* Fix JENKINS-16575 - SEVERE: Failed to record SCM polling - java.lang.NullPointerException - EnvInject Plugin
* Update to envinject-lib 1.15


* Fix JENKINS-16239 - NPE in getRootDir
** Update to envinject-lib 1.14
* Remove Injected from Labels
* Fix JENKINS-16380 - Starting with >1.73 global environment variables overrule build specific parameter variables
* Fix JENKINS-16372 -Password parameter is malformed


* Fix JENKINS-16233 - EnvInject plugin using a cached value for ${WORKSPACE}


* Fix JENKINS-16316 - Global variables not updated
* Fix JENKINS-16399 - SCM documentation is incorrect


* Fix JENKINS-16219 regression from JENKINS-14437 - Version 1.77 injects all environment variables into ANT command line (-D)


* Fix JENKINS-14437 - envinject fails to "really" set/override build parameters


* Fix JENKINS-16016 - Global passwords are visible for matrix configuration builds


* Add currentJob and currentBuild variables for Groovy scripts


* Correct spelling of Password from Password ( merged from pull request)


* Fix JENKINS-15658 - EnvInject Undefines Jenkins Global properties referencing WORKSPACE variable
* Fix JENKINS-15664 - Help text for EnvInject plugin is wrong


* Fix JENKINS-15146 - EnvInject unsets empty string properties returned in maps


* Support for new job types
* Replace "white-list" strategy for supported job types by use of BuildableItemWithBuildWrappers interface to access the job's buildWrapper list.


* Fix JENKINS-15071 - Editing the description of Jobs throws an Error 500 message
* Update to envinject-lib 1.13


* Fix JENKINS-14930 - Can't overload/update PYTHONPATH


* Fix JENKINS-14897 - ConfigFileProvider variable is not seen by EnvInject
* Require Jenkins 1.444+


* Fix JENKINS-14761 - Backslash broken on Properties Content injection
* Fix JENKINS-14768 - Backslash is escaped from injected $WORKSPACE property on slave node


* Fix JENKINS-14686 - Fail evaluating Groovy script before job run


* Add feature - Mask job password parameter value


* Fix JENKINS-14645 - Executing external job results in an ClassCastException (ExternalRun cannot be cast to AbstractBuild)


* Fix reponed JENKINS-14371 - NullPointerException in EnvInjectBuilderContributionAction.buildEnvVars during SCM poll
* Fix JENKINS-14459 - Failed to record SCM polling with envinject plugin


* Fix JENKINS-14371 - NullPointerException in EnvInjectBuilderContributionAction.buildEnvVars during SCM poll


* Fix JENKINS-14367 - Global & node level self-referencing variables should work


* Fix JENKINS-14290 - Support for Ivy project type


* Fix JENKINS-14271 - EnvInject claims global env vars are unresolved on slave


* Fix JENKINS-14284 - Single backslashes are droped or used as escape char


* Fix JENKINS-14232 - EnvInject not handling properties file with logical lines


* Load environment variables from the node (therefore, you are able to redefine classic variables such as the PATH variable at node level)
* Upgrade to envinject-lib 1.8


* Technical release: Merge pull request - Make EnvInjectPluginAction implements EnvironmentContributingAction


* A few minor changes to keep jdk5 compatibility


* Fix regression on backward compatibility


* Remove env variables presence in build serialization file


* Add a complement to fix JENKINS-12423 - Password masked by Mask Passwords are visible when using envinject plugin (no display environment variables when the job is running)


* Update to envinject-lib 1.7 (Enable to external plugin to retrieve envVars)


* Merge pull request - use UnsupportedOperationException instead of UnsupportedMediaException
* Merge pull request - added Japanese localization


* Fix JENKINS-12878 - manage old data fails with RuntimeException: Failed to serialize hudson.model.Actionable#actions for class hudson.model.FreeStyleBuild


* Fix JENKINS-13566 - EnvInject is messing around with my TEMP variable when username contains a dollar sign (windows)
* Update to envinject-lib 1.5


* Fix interaction with multijob plugin


* Add /export/txt, /export/xml and /export/json for the exportation


* Fix EnvInject Password process


* Fix reopened JENKINS-12108 - EnvInject failure using multi-configuration jobs


* Fix JENKINS-13183 - SCM variables resolution


* Fix JENKINS-13157 - EnvInject cannot inject variables whose contents contain a dollar sign ($)


* Fix JENKINS-13167 - Cannot use EnvInject in a Maven 2 Jenkins project


* Fix JENKINS-13155 - Parameters are not working in EnvInject plugin 1.38


* Fix JENKINS-13119 - Add feature: Set an environment variable based on value of user passed parameter


* Fix JENKINS-13085 - Environment Variable Injection doesn't work when project run on slave node that sets the same variable


* Fix JENKINS-13041 - PATH variable is being injected from master on multiconfiguration jobs


* Fix JENKINS-13022 - EnvInject 1.33 doesn''t seem to work with Jenkins 1.454


* Change Environment contributors resolution


* Move global passwords injection to the 'Prepare job environment' section
* Add 'Inject job passwords'


* Fix JENKINS-12944 - Env Inject Plugin doesn't substitute ${WORKSPACE} variable at all when used in 'Preparing an environment for the job'
* Fix JENKINS-12963 - EnvInject plugin causes job to use JAVA_HOME instead of configured JDK


* Fix JENKINS-12936 - EnvInject Plugin 1.30 does not display all properties on job config page


* Fix JENKINS-12905 - PATH variable is not injected


* Fix JENKINS-12876 - Version 1.20 and later removed all comments and new-lines
* Add test to JENKINS-12841 - EnvInject Plugin 1.26 does not substitute ${WORKSPACE} correctly


* Fix reponed JENKINS-12108 - EnvInject failure using multi-configuration jobs
* Fix JENKINS-12841 - EnvInject Plugin 1.26 does not substitute ${WORKSPACE} correctly


* Add a build context to EnvInjectContributor


* Fix JENKINS-12704 - WORKSPACE variable for concurrent builds are not defined properly.


* Fix JENKINS-12809 - Injecting from file removes backslashes on ${WORKSPACE}


* Add the ability to inject password values
* Fix JENKINS-12423 - Password masked by Mask Passwords are visible when using envinject plugin


* Fix JENKINS-12788 - Missing variables when executing EnvInject script


* Fix NullPointerException for a setenv or a envfile migration


* Fix JENKINS-12746 - envinject strips off "\" each time config page is opened


* Move properties content serialization to a Map (avoid carriage return issues)
* Fix usage of build variables for the 'Prepare environment jobs'
* Fix Injected environment vars when EnvInject is not configured


* Fix reopened JENKINS-12423 - Password masked by Mask Passwords are visible when using envinject plugin


* Fix JENKINS-12691 - Property variable not set if using a property file


* Fix migration from the setenv and envfile plugin


* Fix external EnvInjectContribution section display
* Fix text typo

1.15 (technical release)

* Refactoring + fix wrong commit


* Fix JENKINS-12416 - Environment is not injected for each configuration in a multi-configuration project


* Add the extension point EnvInject Job Property Contributor to enable other plugins to contribute to this plugin for the prepare job step


* Fix JENKINS-12423 - Password masked by Mask Passwords are visible when using envinject plugin


* Update to envinject-lib 1.2


* Update to envinject-lib 1.1
* Fix bug on the build end


* Export reuse code to a dedicated library: envinject-lib 1.0
* Fix typo


* Switch properties section and scripts section for the prepare step


* Fix JENKINS-12293 - Incorrect inserting environment variables on linux slave


* Recording EnvVars contributing by other plugins at the end of the build


* Fix JENKINS-12252 - envinject does not fail the build after Environment Script Content fails


* Fix portability in the history build.xml file (using the build reference instead of the absolute path of the EnvInjected file)
* Add the ability to load a properties file at node startup (at master and/or at slave startup)


* Move 'Triggered Build Cause' to Jenkins build variables option
* Add an export option to export environment variables to TXT, XML or JSON


* Fix NullPointerException when master has 0 executors


* Fix JENKINS-12108 - EnvInject failure using multi-configuration jobs
* Fix JENKINS-12084 -Variables resolved alphabetically rather than order found in content/file. ${WORKSPACE} not always getting resolved as result
* Accept script parameters to script path sections


* Fix JENKINS-12027 - ${WORKSPACE} variable doesn't use my specific workspace directory anymore in a build step
* Make it stable for production


* Enhance display log
* Refactoring for fixing properties variables propagation


* Fix JENKINS-11763 - Can not set some 'special' variable names the first time
* Technical Refactoring


* Make it extensible by an another plugin.


* Fixed JENKINS-11595 - Some env variables can not be used to inject, for example $NODE_NAME


* Add the ability for the 'prepare environment' feature to load the properties file and the script file from the master node even if the build runs on a slave node.


* Add global properties and node properties process


* Fix JENKINS-11439 - Can't add "environment inject" to pre-scm-buildstep plugin.


* Fix JENKINS-11181 -Variables failing to be set if referencing previous variable


* Fix JENKINS-11067 - Pre-SCM and Post-SCM environment scripts do not use Pre-SCM and Post-SCM properties


* Fix JENKINS-11066 - Property Variables "Randomly" Not Working/Getting Unset


* Fix JENKINS-11063 - Multiple "Inject Environment Variables" Build Steps All Show Same Content


* Backslashes in file path for windows platform are managed
* Added feature 'unset variable' when the variable is unresolved


* Integrate domi pull request (add trigger causes as environment variables)
* Fix JENKINS-10980 - EnvInject to optinally trim trailing spaces


* Improve reporting errors


* Fix JENKINS-10919 - Variables are shared between jobs


* Fixed JENKINS-10916 - Properties not injected and build marked as failed

0.11.1 (technical release)

* Remove unused maven dependency


* Fix JENKINS-10894 - Inject environment variables with property file not working


* Add the ability to unset system variable at node level
* Add an option to 'Keep Jenkins system variables'
* Fix JENKINS-10845 and JENKINS-10877 - master/slave sync / Job variables/parameters are missing
* Complete the fix to JENKINS-10847


* Fix partially JENKINS-10847 and JENKINS-10845 - Enivronment is not separated
* The ability to 'Keep system variables' has been removed. The feature will be restored later (and moved at slave/node level (not at job level).


* Fixed variables restauration for Maven jobs


* Fixed variables propagation between typologies
* Fixed variables restore for all typologies


* Add a 'Keep Jenkins Build variables' option
* Add 'EnvInject' as prefix for plugin log messages
* Sort the EnvInject variables table


* Remove advanced sections


* Add a build wrapper
* Fix serialization fiels for JobProperty
* Add a migration procedure for setenv and envfile plugins


* Add variables resolution in elements


* Fix environment script content process


* Can inject environment variables as a build step.


* Initial versio


  1. Unknown User (edovale)

    It would be nice to see a screen shot of this plugin configuration.

    1. Unknown User (gbois)

      Thanks for your suggestion.

  2. Unknown User (edovale)

    Awesome plugin!!!!

  3. Unknown User (andyhitchman)

    Is it possible to substitute in existing env vars?



    We're installed on W2K8

    1. Unknown User (gbois)

      Yes it is possible to substitute environment variables in text value.
      However, ${BUILD_TAG} was not available.
      I added in version 0.6, a 'Keep Jenkins build variables' option aimed at providing these kind of variable.
      You have to check this option for your need.

      1. Unknown User (leovonklenze)


        I tried that with ${WORKSPACE}

        . Unfortunately I'm bound to a windows box and the \ in the path is not escaped correctly.

        Can you fix this, please?

        Thank you!

        1. Unknown User (gbois)

          What do you expect exactly?
          Please could you give your use case?

          1. Unknown User (leovonklenze)


            I wrote the following to properties content:


            since my program needs that envrionmental variable to know where its output should go.

            Unfortunately the following value is injected:


            instead of


            If I give the absolute pathname, I've also to write


            Thats ok for me, but if using a placeholder the plugin should automatically escape the backslash-character.

            Thanks, your plugin is very usefule for me!

  4. Unknown User (jswager1)

    There seems to be a problem with this plugin.  When values are injected as a build step WHEN THE JOB IS RUN ON A SLAVE, it also sets the variables for all future jobs run on the slave.  In addition, it strips away all the normal user/system variables and only displays on the Jenkins, job and injected variables.

    1. Unknown User (gbois)

      Thanks for raising this problem.
      I fixed it in version 0.7

      1. Unknown User (jswager1)

        Waiting for v0.7 with bated breath...  If it does work, this will make my jobs MUCH easier to maintain.  

        1. Unknown User (leovonklenze)


          does not work for me. Environmental variables are still spreading to other jobs:

          Maven Job -> Building Environment -> Inject environment variables to the build process


          1. Unknown User (gbois)

            Thanks for reporting this issue.
            The fix is available in release 0.8

      2. Unknown User (hizuya)

        I used version 0.7.  When the job with 'Keep System Environment Variables' option is run on a slave node, it used system environment variables ON A MASTER NODE.

        I want to use slave node's system environment variables.

        1. Unknown User (gbois)

          Are you sure?
          I can't reproduce the issue.

          1. Unknown User (hizuya)

            hm. My master node's "# of executors" is "0". There are two slave node, which connect by jnlp.

            Theses nodes is running on windows server.

            free-style job -> Prepare an environment for the job (checked) -> Keep System Environment Variables (checked), and "foo=bar" in the Properties Content

            If the Properties Content is empty, it does work.

            I checked in "Injected Environment Variables" view, and "set" build command.

            1. Unknown User (gbois)

              Could you raise an issue with screenshot and your job configuration file (config.xml) in attachment?

              1. Unknown User (hizuya)

                OK.  Please see JENKINS-10845.


  5. Unknown User (jswager1)

    I would STRONGLY recommend not to use v0.9 at this time.  See JENKINS-10877.

    On our system - where we wipe workspaces with a "del %WORKSPACE%*.* /s /e", EnvInject v0.9 fails to populate %WORKSPACE% and resulted in wiped hard drive.

    1. Unknown User (gbois)

      In all the cases, i strongly recommand to check if a variable is set before executing a script with this variable and the force option

      I fixed it. You have to use 0.10

      1. Unknown User (jswager)

        Yeah - I can see checking all variables.  It just comes as a bit of shock when standard Jenkins variable suddenly disappear after installing a plugin.  I could see them disappear after using the plugin in a job, but after installation?

        As it is, I grabbed v11 you referenced in one of the defects and it passed all the tests I had for it.  This plugin in is pretty powerful - it's the closest thing there is to conditional control within a job.  I suspect that even if conditions are added to build steps, we'll still need this plugin to control the variables that build step conditionals will probably check for.

        Great job on the plugin!

  6. Unknown User (bogdaniosif)

    It would be very useful if the user could add env vars defined in a file BUT ALSO be able to show/edit the file in the job's config ui.

    Having the env vars defined in a file creates the [potentially ugly] problem of requiring an additional channel to see/edit that file.

    If you could add this feature it would create a unique functionality, that is a hybrid between setenv and fileenv.

    1. Unknown User (jswager1)

      At least for me, any file that I use is generated during the build.  So being able to edit the file at design time is useless because the file doesn't exist.  Also, you could use the Environment Properties Content to do away with a file entirely.

    2. Unknown User (gbois)

      The plugin already enables you to provide variables in the job configuration UI (fill in the textarea with key/value pairs) : please look at the screenshot.
      Moreover, the plugin enables you to also inject variables from properties file.
      Therefore, one feature of the envinject plugin is to provide an hybrid between the setenv plugin and the envfile plugin.

      1. Unknown User (bogdaniosif)

        I fully understand the current functionality. What I was requesting is something more than what is currently available: To be able to store in a properties file, env vars editable in a textbox in the job config UI.

        It's very valuable to have those env vars stored in a file but the big problem with having them in a file is that they are not visible to someone who looks at a job's configuration from the Jenkins UI. They are also not as easily editable.

        I would even be happy just to be able to see, in read-only mode, the env vars configured in a given file.

        Is it clear that what I need is not covered by the current versions of envfile, setenv or envinject?

        1. Unknown User (gbois)

          OK, If I understand, you want Jenkins to provide for example a link to display of popup with the file content (in readonly).
          Could you raise a ticket to keep track of this request?

          1. Unknown User (bogdaniosif)

            Done, https://issues.jenkins-ci.org/browse/JENKINS-10899

            Thank you very much for the help.

            I'm hoping the file can be shown inline and that it can be edited from the config UI. However, I understand why technically those desires are problematic. For example, it could be tricky if one uses in a job configuration the envinject plugin both during a build's main steps and during promotion steps, referring the same properties file. This is actually exactly what I need to do.

  7. Unknown User (luispiedra)


    I've trying EnvInject plugin, but I've found one problem. I'm developing a plugin for ACM access, and while I can access new defined environment variables from an AbstractBuild objects in checkout and calcRevisionsFromBuild, I'm not so lucky in the Polling process, compareRemoteRevisionWith method where I don't have an AbstractBuild object but an AbstractProject where I can do project.getLastBuild(). The problem is that injected variables are not persisting so when I retrieve the environmet of the last builds, new variables are not present. Is there a way to have access to variables injected in previous builds?


       Luis Piedra


    1. Unknown User (gbois)

      You can access latest injected environment variables by the following URL

      If you want to have in:

      • a XML format: <jenkins_url>/<job>//lastBuild/injectedEnvVarResult/api/xml
      • a JSON format: <jenkins_url>/<job>/lastBuild/injectedEnvVarResult/api/json

      By Api, you get the latest build object and retrieve the EnvInjectAction action object.
      Then there is a getter method to retrieve all variables.

  8. Unknown User (pixman20)

    Only version 0.15 is available in the Jenkins Update Center.

    What needs to be done to make 0.18 available?


    1. Unknown User (gbois)

      Maybe an update center problem with your infrastructure.
      Please send a message to the Jenkins users mailing list.

      Waiting for the fix, you could download the lasted plugin version in the Maven repository (http://maven.hudsonlabs.org:8081/content/repositories/releases/org/jenkins-ci/plugins/envinject/0.18/) and install it manually.

  9. Unknown User (jessej)

    It doesn't seem like this plugin might have a problem with multi-config projects where the Jenkins build vars are not passed to each configuration (eg: BUILD_NUMBER, BUILD_TAG, etc...) 

    1. Unknown User (gbois)

      Please could raise an issue?

  10. Unknown User (jlpinardon)

    Well, very interesting "unifying" plugin. Thanks.
    But... I would like to inject a file with a path defined with a variable set as an instance global property.
    The configuration is as follows
    For sure, I have checked that the value is correcty set.

    I also tried with

    ${ENV, var="JENKINSVAL_DATAPROPS_PATH"}/test_props.txt

    ... for the same result. The error message in the console log is :

    EnvInject - ERROR - The given properties file path ${ENV, var="HUDSONVAL_DATAPROPS_PATH"}/test_props.txt doesn't exist.

    So it seems that variabes are not interpreted here... or perhaps the syntax is not the correct one ?

    Thanks for the help.

    1. Unknown User (gbois)

      The EnvInject plugin is not only an aggregation of the sentenv and the envfile plugin.
      It provides more features such as the ability to prepare an environment by injecting variables and executing setup scripts.

      For your use case with global properties, it was a missing feature. It wasn't taken into account. I fixed it.
      Please upgrade to version 0.21 and use ${JENKINSVAL_DATAPROPS_PATH}.

      1. Unknown User (torr)

        I think there's been a regression here.

        I'm attempting to use values set during a previous promotion to inject properties into the current promotion:

        However, EnvInject cannot resolve the promoted id. I output it in a shell execution and it is known before the injection, but it still fails:

        + echo 2013-08-28_14-51-48
        build hudson.tasks.Shell@2518eeb6 SUCCESS
        [EnvInject] - Injecting environment variables from a build step.
        [EnvInject] - [ERROR] - The given properties file path '../builds/${PROMOTED_ID}/.alpha' doesn't exist.
        [EnvInject] - [ERROR] - Missing file path was resolved from pattern '../builds/${PROMOTED_ID}/.alpha' .

        Please advise.

  11. Unknown User (rmyung)

    I really like the way this plugin works, thanks!

    There are a few things I've had trouble with, however.

    1. It seems like the PATH variable is inaccessible in the "Properties Content" section

    2. I'm having trouble accessing the variables I set in "Properties Content" in "Environment Script Content".  It's unclear to me what the correct syntax for dereferencing the variables should be.  Is this block of code done using the system shell?  I'm using a Windows machine.

    1. Unknown User (gbois)

      Thanks for using the plugin.
      1) Did you try $PATH or ${PATH}?
      2) Could you try the latest version (0.26). It should solve your issue.
      If your problem persists, could you fill in a ticket in the Jenkins issue tracker for the envinject component?
      And make sure you attach your job configuration file (config.xml) so that I can try to reproduce the problem.

      1. Unknown User (rmyung)

        I've tried both syntaxes for PATH.  I've entered a ticket for this.

        The new version fixed the second problem, thanks! 

        1. Unknown User (gbois)

          I'll update your issue.

  12. Unknown User (ferda)


    I have problem with new plugin 1.5/1.6 (1.2 works well) on slave (linux) node. I've tried this plugin using "Inject environment variables to the build process" in "build environments". I used cmakebuilder plugin (not significant). Although a building process fail with cmake errors It is probably error in EnvInject plugin 1.5 version because the building process in 1.2 is ok. Bookmarks "Injected Environment Variable" in 1.2 contains environment variables from linux (slave), but 1.5/1.6 contains environment variable from windows (master). Thanks!

    1. Unknown User (gbois)

      Could raise a bug report in the Jenkins issue tracker?

  13. Unknown User (pezzu)

    Looks like plugin doesn't work correctly with 1.446. I can't have it to pass system variables to slaves.

    1. Unknown User (gbois)

      Could you try to isolate the problem and raise a bug report?

      1. Unknown User (pezzu)

        My problem appear to be not with Jenkins version but with EnvInject.

        I found similar issue registered already: JENKINS-12293 and updated it with my findings.


        1. Unknown User (gbois)

          Fixed in 1.7.

          1. Unknown User (pezzu)

    2. Unknown User (gbois)

      Does the problem persist with EnvInject 1.7?

  14. Unknown User (prenaud76)

    First, many tx for this plugin as it solves an issue I had with having the environment defined in time for the execution of the Release plugin. Now it works! :-)

    Is there a way to run a script to "calculate" a value before the build and save it in a variable/property that is available throughout the build? What I am asking for is something like an extension to the Environment Script Content box where commands could be executed not only to create folders and so on but also to dynamically assign a value to a property that would be accessible to subsequent build steps. Is it possible today? If so, can you show how?


    1. Unknown User (gbois)

      As a build step, you can execute a script creating a properties file and then inject the properties file in a next step by the EnvInject plugin (EnvInject plugin provides a build step named 'Inject environment variables for your job).
      However, at the moment, you can't execute a script at the begining of the job that fills in a properties and injects it after.
      For this request, I have to process the properties section after the script section.
      Please could you raise an enhancement in the Jenkins issue tracker for the 'envinject' component?

      1. Unknown User (rmyung)

        I'd love this feature too.. I'm specifically looking at the case of mapping a drive on Windows (using net use), and storing the drive mapped as an environment variable.

        Is there a way to run "cleanup" too?  I'd like to remove the drive mapping after use.

        1. Unknown User (gbois)

          Please could you try the version 1.8?
          Execute a script executing your mapping drive and fill in a properties file.
          Then load this new created properties file in the properties section to get the properties variables.

          Regarding the cleanup at the end of the build, I suggest you should look at the PostBuildScript plugin

  15. Unknown User (frederic_latour)


    I don't know if it's easy or not (or even impossible) but one great additional feature would be the ability to set environment properties from the parameters default value defined in some other job.

    The great advantage of this approach is that it would make it unnecessary to mess with some file. By using some fake job, I would be able to specify some parameters and default values that I could use in any job thanks to this plugin.

    Does it make sense?

    1. Unknown User (gbois)

      In my opinion, a job has to be executed in isolation from other jobs. Therefore, I don't like the idea to reuse some configuration elements from other jobs, except if it is a template job.
      For the EnvInject plugin, you can load global properties file from the node.
      Does it suit you?

  16. Unknown User (prenaud76)

    During a Release build (via the Release plugin) I need to run additional steps where I need to make calls to tools that were auto-installed, such as Git and Maven for example. The Tool Environment plugin (https://wiki.jenkins-ci.org/display/JENKINS/Tool+Environment+Plugin) is very useful in that it sets an environment with the location of the wanted tool and I make good use of this during a normal build. My problem is that this plugin runs too late in the context of the Release plugin and I am left out luck as to knowing the location of the automatically installed tool(s). I was hoping the EnvInject plugin could come handy as it runs much earlier in the build process and in fact in time for the Release plugin, but there does not seem to exist an easy way to extract the location of those auto-installed tools again.

    Would you be able to suggest a way to do this? Or maybe do you see this as a useful addition to the plugin instead?

    Any suggestion is welcome.

    1. Unknown User (gbois)

      I'll add this feature as soon as possible

      1. Unknown User (gbois)

        I made a new plugin for this feature: the shared objects plugin.
        This plugin makes it possible to share objects in Jenkins. At the moment a shared object can be a public file path, a Clearcase object path or a native tool installation.
        Each object is propagated in the job as environment variables.

        Please feel free to provide any feedback.

  17. Unknown User (sherriexma)

    Thanks a lot for the great tool!

  18. Unknown User (prenaud76)

    Is it possible that the variables aren't injected at post-build time when Sonar executes? No matter what I do it seems that Sonar always runs despite the value of the variable I specify in the "Skip if environment variable is defined" field. However, it works correctly and as expected if I specify a variable that is a build parameter instead of a variable injected by the EnvInject plugin.

    1. Unknown User (gbois)

      Could you raise a bug report in the issue tracker and attach your job configuration file (config.xml)?
      I'll try to reproduce the issue and fix it.

  19. Unknown User (nnau)


    I have master/slave setup, and my project has the ability to execute builds in parallel, i.e. I have 'Execute concurrent builds if necessary' option turned on. 

    But when I'm trying to inject any environment variables into my job ( 'Inject environment variables to the build process' option ), then the $WORKSPACE variable is NOT defined properly for parallel builds. 

    They should be


    But $WORKSPACE always points to


    for all jobs

    1. Unknown User (gbois)

      Ok thanks for raising this issue.
      The issue is able to keep track of in the issue tracker: issue #12704

    2. Unknown User (walterk82)

      I'm not sure how the variable is handled but I don't have "'Execute concurrent builds if necessary'" enabled and I still see workspaces defined with @2, @3, @4, etc...  Is there a way to stop this from happening?

      1. Unknown User (gbois)

        Strange behavior!
        With Envinject 1.28, the plugin does not compute the workspace value but get it from the current build.
        I tested and it seems to be OK. Are you using version 1.28?

        If the issue persists, could you raise a bug report and attach your job configuration file?


        1. Unknown User (walterk82)

          OK, I posted my comment before I saw that 1.28 is available.  I have updated and my problems seems to be resolved.  Thanks!

  20. Unknown User (nnau)

    Hi again! 

    With 1.29 update $PATH variable is not redefined: 


    [EnvInject] \- Executing scripts and injecting environment variables after the SCM step.
    [EnvInject] \- Injecting as environment variables the properties content
    [EnvInject] \- Variables injected successfully.
    [EnvInject] \- Unset unresolved 'PATH' variable.
    [testPATH] $ /bin/sh \-xe /tmp/hudson2831645515572899066.sh
    + echo /usr/local/bin:/bin:/usr/bin
    + echo aaaaa

    Is it a bug? I need to redefine $PATH to use within actual build.

    1. Unknown User (gbois)

      Fixed in 1.30

  21. Unknown User (majje)

    Can I use this plugin to inject a variable containing downstream jobs, which I can use during a build action or a post-build action? Before I upgraded my Jenkins installation I was able to do this during a build action, but now I can't. Was that a bug or was I just lucky for a moment ;)

    1. Unknown User (gbois)

      I don't know if there is a variable referencing the downstream job (maybe provided by an other plugin).

  22. Unknown User (walterk82)

    Is it possible to hide values from the "Injected Environment Variables" section like usernames or passwords?

    1. Unknown User (walterk82)

      1. Unknown User (gbois)

        You can't use mask-passwords plugin and envinject plugin together.
        However, EnvInject plugin enables you to define global passwords and these passwords can be injected as environment variables and they are hidden in the Jenkins log, in the exported envinject variables section, ...

        1. Unknown User (walterk82)

          Darn, I need to use mask passwords because username/passwords need to be defined uniquely for each job but I would like to use the same $VARIABLE

          when referencing them in my build scripts.   Thank-You for your help.

          1. Unknown User (gbois)

            Waiting for the add of password per job, you can use password parameters given them a default value.
            Password parameters are managed by the envinject plugin (parameters will be injected as environment variables, password parameters are hidden in the envinject reporting page, ...)

          2. Unknown User (gbois)

            From EnvInject 1.33+, you are able to use envinject job passwords in 'Prepare job environment' section.

            1. Unknown User (walterk82)

              This works great!   It also eliminates my particular needs for the Mask Passwords Plugin.

  23. Unknown User (grayaii)

    How do you roll back to a previous version of this plugin? 

    We were at 1.35 and then we upgraded to 1.38, but ran into a bunch of problems:

    13136 - Environment Variable Injection injecting (and overriding) unwanted variables (ie JAVA_HOME)
    13041 - PATH variable is being injected from master on multiconfiguration jobs

    At 1.38, all our jobs are pretty much broken because our jobs are inheriting the environment from Jenkins Master.

    So we rolled back to 1.35 where our jobs were passing (we can confirm that we are at 1.35 by going to Manage Jenkins->Plugins) , but they are still exhibiting the same behavior as if we were still at 1.38!

    What do we have to modify/remove to get our Jenkins master back to the state that it was at? Does this plugin tweak the job's config.xml? Or are there some files that we have to manually delete to get it back to its original state.


    1. Unknown User (gbois)

      To uninstall the plugin:
      a) Stop the Jenkins instance
      b) Go to $JENKINS_HOME/plugins
      c) Remove the envinject folder and the file envinject.hpi
      d) Put the new hpi envinject file to install
      e) Start the Jenkins instance

      Your selected envinject plugin version can be downloaded here:http://maven.jenkins-ci.org/content/repositories/releases/org/jenkins-ci/plugins/envinject/

      For your issue, please raise a bug report.

  24. Unknown User (pxantom)

    I've issue with fresh plugin (1.38). See details JENKINS-13155.

    I would be very appreciated if you could look at it.

    1. Unknown User (gbois)

      Issue fixed.

  25. Unknown User (thorarakis)

    I'm having trouble getting the P4_CHANGELIST variable. It appears that the variable isn't usable in the 'build environment' or the 'build step' inject sections. It appears that both of these should be executing after the scm steps. I set the 'Keep Jenkins Environment Variables' and the 'Keep Jenkins Build Variables' with no success. Are there other settings I need to toggle to preserve environment variables for after the SCM steps?

    If I check the variable during a shell command build step it appears to be set correctly:

     echo ${P4_CHANGELIST} 
    1. Unknown User (gbois)

      Do you know which plugin provides this variable?
      Please could you report a bug and attach your job configuration file?

      1. Unknown User (thorarakis)

        This is from the perforce plugin, however it looks like as of version 1.44 this is fixed. No need to file a bug then =)


  26. Unknown User (chrisr)

    We just tried using the EnvInject plugin to set a computed environment variable within a particular job only, on an "opt in" basis. The intention was for the plugin not to affect any other jobs in any way. However, one of our Scons builds has suddenly started failing with missing environment variables which had previously been set successfully on the command line:

    e.g. cmd VAR1=xxx VAR2=yyy

    The obvious conclusion is that activating the EnvInject plugin immediately changes Jenkins' global behaviour in an extremely unwanted way, and unless we can get the previous behaviour back then we're going to have to throw this plugin away. Can anyone suggest what the plugin is doing and how we might fix it, please?

    1. Unknown User (gbois)

      Could you raise a bug report and attach your job configuration file?

      1. Unknown User (chrisr)

        I don't have access to the XML configuration for the particular failing job, although I do recall that it is a "matrix" project that executes its build on a slave node.

        One other thing I noticed: the job pulls its sources from a single SVN URL, but the SVN_REVISION environment variable is not included in the list of "Injected Environment Variables".

        Also, the job that failed ran on a Win32 node. However, the configuration that ran on the OSX node succeeded.

        1. Unknown User (gbois)

          Unfortunately, without more inputs, I can't try to reproduce it and fix if there is a bug.

          1. Unknown User (chrisr)

            We've just upgraded to the latest version of Jenkins (from 1.443), and will need to test if the problem still happens. Failing that, I'll try to get hold of this build's config.xml file.

            Disabling the plugin has fixed the build, so it's definitely something that EnvInject is doing.

            1. Unknown User (gbois)

              Please raise a bug report for the envinject component when you will have all information.

  27. Unknown User (bedge)

    I'm having problems using this when trying to share common build paths for the artifact archive step.

    I added this to the props file, and it is shown in the injectedEnv.txt:


    My archive artifacts line contains:

    \${APP1_ARTIFACTS}   (leading \ needed to prevent in-line expansion error in this context)

    However, post-build, nothing is copied to the artifacts dir.

    Is some form of escaping needed for either "," or "*" characters?

    1. Unknown User (bedge)

      Never mind, figured it out.

      One of the paths was wrong. It's difficult to tell as there's no working or logging for any of the artifact archival process. You just don't get the files you expect.

      A verbosity config setting would have been very helpful here.

  28. Unknown User (mharris)

    I'm trying to use a properties file with a single key which has it's values spread over multiple logical lines.  I use the key as a list of jobs to trigger using the Jenkins Parameterized Trigger plugin (v2.15) however it tries to trigger a job called \ rather than ignoring it and stops triggerning jobs after the first \.  It works ok if I remove all the \ characters and leave it as a single line, but with a list of 20 jobs it becomes difficult to read and update the properties file and my developers prefer using the logical lines.  I'm not sure if this is an issue with the EnvInject plugin or the parameterized trigger plugin.

    I'm using 1.467 of Jnekins and 1.50 of the EnvInject plugin.

    1. Unknown User (gbois)

      Could you report a bug in the Jenkins issue tracker for the envinject and parameterized components. Attach your job configuration file (config.xml) and we will analyze it.

  29. Unknown User (bpancost)

    I've been setting up a number of builds that require different path environment variables and I decided to give this plug a try. The thing is, I'm not getting the path variable that I set in "Prepare Environment for Run" when I run build steps with a shell script or a windows batch file. I tried to echo the path as a build step and the result is the original system path, despite the fact that I have set replacement values as well as checked in the node configuration to unset system variables. Is there some other step that I would need to do?

    1. Unknown User (gbois)

      At the moment, it is not possible to source a file.
      Therefore, set the path in a prepare environment script has no effect.

  30. Unknown User (nluetic)

    I defined a Groovy script in "Prepare environment for run" to set some environment vars based on a parameter value, which are subsequently evaluated.

    This works well with "Free Style" build jobs. However, if I the job type of the main job is "Build Flow" the script does not seem to be evaluated as I don't see any log message saying so and the environment variables do not exist in the jobs I call from there.

    Is this an error in EnvInject? Or in BuildFlow?

    If Build Flow is not supported the EnvInject Options should not appear there.

    1. Unknown User (gbois)

      At the moment, Envinject plugin doesn't work for a job type of Build flow.
      This issue relies on the build flow plugin.
      Please report an issue for the build-flow component.
      However, defining new job type is always a big deal and need for this new type to handle proprely all plugins.
      And with the large Jenkins plugin ecosystem, we have difficulty to handle that.

      EnvInject is first class-citizen for Free-style job type.

      1. Unknown User (jrws)

        @Neven - I use freestyle jobs with the Build Pipeline Plugin to create "flows" - and I am adding EnvInject into those builds now. I will post here on how well it all works together.

        1. Unknown User (gbois)

          I don't know if the EnvInject plugin is compatible with the Build Pipeline plugin.
          If not, please report an enhancement for the build pipeline plugin.

          1. Unknown User (jrws)

            So far, so good. I am passing a gitish along the pipeline and building from a detached HEAD. At the start of my job I set an environment using EnvInject, and it is working as advertised, and none of the features in the Build Pipeline plugin are being interfered with.

            1. Unknown User (nluetic)

              Been away for a while ...

              Trying to represent my job pipeline with Build Pipeline didn't work for me, although seemingly for other reasons than with BuildFlow.

              I defined a start job, that only sets some environment variables via a groovy script. In the downstream jobs I do find a list of "Injected environment variables", however those set by the start job are missing.

              Could you describe, what you did in more detail?

              1. Unknown User (gbois)

                It's not an issue of your configuration.
                At the moment, it is only an issue between the EnvInject and Build-flow plugins.

                1. Unknown User (nluetic)

                  Like I said: it's BuildPipeline this time.

      2. Unknown User (ndeloof)


        Envinject uses a white-list for supported job types, any plugin to define a new type (like build-flow does) will require an update, so the issue is on envinject side :P 


        This is a general issue with this white-list approach, that will prevent integration between envinject and any non oss plugin to define custom job type.

  31. Unknown User (lfalberti)


    We're using Config File Provider which sets an environment variable to the path of the file it provides, however that value doesn't seem to carry over in EnvInj and results in an "unresolved variable" error. It's the same behavior that I get with ToolEnv if I don't activate ToolEnv in "prepare environment for run", so I assume it's because Config File Provider isn't EnvInj aware.

    My questions are: Is my diagnosis correct, and ConfigFileProvider should be changed to be compatible with EnvInj? If so, can you give me some directions in terms of what the change in ConfigFileProvider should be to help EnvInj use it's file path variable?

    Thank you

    1. Unknown User (gbois)

      Track with JENKINS-14897

  32. Unknown User (aodo)

    I'm trying to use a combination of parameterized build and envinject and I've run into a bit of a problem...

    Lets say I have a build parameter named "test param' (yes spaces, no, no quotes).

    In "Inject environment variables to the build process" I attempted to map it using "Properties content" , like this:

    MY_NEW_PARAM=${test param}
    or like this:
    MY_NEW_PARAM=${test\ param}
    or like this:
    MY_NEW_PARAM=$test param
    All result in:[EnvInject] - Unset unresolved 'MY_NEW_PARAM' variable.

    Any ideas on how I can use properties with spaces?


    1. Unknown User (gbois)

      Jenkins enables you to define build parameter with spaces.
      However, I think it is a mistake because it is not allowed in environment variables names.
      Remember that EnvInject plugin (through properties and other elements) enables you to control environment variables for the build.
      Therefore, you can't define properties with spaces for the EnvInject plugin.

  33. Unknown User (walterk82)

    Where can I find the published Javadocs for this plugin?  I'm trying to write a system groovy script that will update the Job level passwords section.

    1. Unknown User (gbois)

  34. Unknown User (rrialq)

    Is there a way with a groovy script to return variables which should be considered as passwords?

    For example, I have a groovy script that returns the variables:


    But password are show in clear text at injected variables.

    It should be great that the plugin would inject a variable starting with encrypted. (or another prefix) as a password variable, so at Jenkins Injected Environment Variables it should appears encrypted.


    At previous example, user is injected in clear text, but password should be injected as a password (encrypted.password), so it's clear value is available at build process, but at logs and screens it should be showed encrypted.

    1. Unknown User (gbois)

      It could be a great idea. However, I have difficulty implementing this new feature with the current code for now. At the moment, the design is too complex.
      In addition, if you look a the Password parameter, it is in plain text in the Jenkins log.
      Therefore do you want the same behavior as job password parameter.

  35. Unknown User (jstarbird)

    I'm using the Job Exporter plugin which dumps another job's Env Variables into a properties file which I am then trying to use with Env Inject on a secondary job so that I can share some values.

    The Job Exporter sets all it's properties like build.number, job.number, etc.  When I try to use these in the secondary job it's not working.

    I've tried

    ${ENV, var="build.number"}

    and none of them will work.  I've even tried assigning them to new variables in the Properties Content.

    I'm using Jenkins 1.480.3, 1.83 of the EnvInject plugin and 0.4 of the Job Exporter plugin.

    1. Unknown User (gbois)

      Job Exporter plugin provides a properties file where property name contains a '.'.
      Unfortenately, Jenkins (and therefore EnvInject plugin) can't understand environment variables with '.'
      I suggest you should raise an issue for the JobExporter plugin

      1. Unknown User (jstarbird)

        Thanks. That's sort of what I was afraid of however I did get it working with the Email with the

        ${ENV, var="version.string"}

          format. Which I use EnvInject to read out of a property file so based on what you're saying that shouldn't work?

        Overall there are several plug-ins where the dot in the environment name works fine and some where it does not, it seems things are being done inconsistently in the plugins.

        In any event now that I know the issue I can work around it somehow. The only issue I have now is with Publish over SSH.

        I am a bit puzzled why a variable with a period in it is a problem, I'm familiar with 7-8 scripting languages and all of them can handle it.



  36. Unknown User (achoo)

    Quick question: For "Properties File Path" I'd like to be able to refer to a build parameter called "SlaveOS". Is this possible?

    I've tried the following but they don't seem to be right:

  37. Unknown User (l_roche)

    In many builds, I have randomly this error

        EnvInject - Loading node environment variables.
        EnvInject - ERROR - SEVERE ERROR occurs: null

    I don't find how this can happen and there is nothing in the log. Or I missed it.

    This happens before the execution of a script, right?
    So, something bad in the node env can trigger this error?

    I really need some help on this case.

  38. Unknown User (achoo)

    Quick question: Does Evaluated Groovy script run on the Jenkins master or on the slave node?

  39. Unknown User (waeldarwich)


    I am using EnvInject 1.85 with Jenkins ver. 1.512 and I found that when EnvInject is installed I lost both LD_LIBRARY_PATH and PATH system variables from Linux master node, using Prepare jobs environment &/| Unset System Environment Variables made no difference at all, all other Environment variables I set on master config are ok

    I rebooted Jenkins and still no success!

    Any idea?

    Thanks in advance

    1. Unknown User (waeldarwich)


      Thanks a lot, I see you already started working on 1.86, you are a star

      I do not want to be pushing, but do you know when this will be available, I've tried to set PATH using different ways but could not, the only solution I had is to uninstall the plugin, which meant I lost its really powerful use

      All the best

  40. Unknown User (waeldarwich)


    I've tested the new 1.86 and it is the same as 1.85, I still cannot set PATH for Linux master

    Thanks anyway for your help


  41. Unknown User (waeldarwich)


    I've tested the new 1.87 using Jenkins ver. 1.512 and restarted but it is still the same as 1.85, I still cannot set PATH for Linux master at all!

    In master node properties I can set Environment variables in general, it just ignores LD_LIBRARY_PATH and PATH while others are used proeprly


  42. Unknown User (sventhegrinch)

    I hope this is the appropriate way to report an issue (if not, please tell me and I will do it differently). 

    After upgrading to Jenkins 1.521 it seems that this plugin is breaking the job configuration dialogs (they get stuck in Loading). Disabling just this one plugin resolves the issue (but of course I loose all the env inject goodness :-( ). The server is on Ubuntu 12.04 64 bit (doubt that is relevant). I am using Chrome 27.0.1453.116 on Mac 10.8.4. Getting the same with the latest Firefox, so this looks like a general issue. I am all current on my plugins (including this one) of course).

    My javascript console shows:

    Uncaught TypeError: Property 'on' of object #<HTMLFormElement> is not a function (textarea.js:18)

    Is there anything else I can do to help diagnosing this issue? Any additional data? 

    1. Unknown User (sventhegrinch)

      Upgrading to 1.522 fixed the issue.

  43. Unknown User (arpitgold)


    We are getting issue in retrieving Global Password Field.

    Steps to reproduce

    Step 1 : 

    Add a Global Environment Variable :
    Step 2 : 

    Add a promotion Step in Job and trying to access Global build password field :
    Step 3 : In Output we are not getting value it is empty string


    Please provide the solution for the same.


    Arpit Nagar

    1. Unknown User (holoadmin)

      You have to use it like this

          ECHO %ENV:GlobalBuildPasswor%

  44. Unknown User (nluetic)


    I have an issue with setting environment variables via a properties file.

    Setting a properties file in the global config only affects the master - the slaves do not get the properties defined there (the properties file exists everywhere under the same path).

    Defining a properties file per node gave me the following results:

    master: a property that was differently defined in the property file given for the node specifically, didn't change; a property only defined in the node-property file was not visible

    slave: none of the properties from global or node specific properties file were visible

    Nodes were restarted after making the change.

    Giving a properties file per job works in any case.

    Expected behaviour:

    * read properties defined globally on any node

    * read properties defined per current node, overwriting existing global properties

    * read properties of job, overwriting existing properties

    Currently it seems that the properties file per node is being ignored while the global property file only affects the master.

    Please tell me if You can reproduce this behavior and if there is any workaround.




  45. Unknown User (rodriguesalex)

    Specifications of environment
    master (Jenkins server) installed on Red Hat Enterprise Linux Server release 5.7 (Tikanga), Jenkins ver. 1.509.3
    slave installed on Red Hat Enterprise Linux Server release 6.3 (Santiago)
    Ver of plugin used is 1.89
    Defined a variable LB_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/IBM/db2/V9.5/lib64 at the node level of the slave. prior to installing this plugin, was able to access LB_LIBRARY_PATH value from the node when running the job (verified by echoing the value of the variable during the job run). After installing the plugin, can no longer access the value from the node, even though not using the "Prepare an environment for the run" section.To work aroudn the issue, I needed to enable "Prepare an environment for the run" and then disable "Keep Jenkins Environment Variables" and "Keep Jenkins Build Variables"
    Specifications of environment

    • master (Jenkins server) installed on Red Hat Enterprise Linux Server release 5.7 (Tikanga), Jenkins ver. 1.509.3
    • slave installed on Red Hat Enterprise Linux Server release 6.3 (Santiago)
    • Ver of plugin used is 1.89

    Defined a variable *LB_LIBRARY_PATH=$

    Unknown macro: {LD_LIBRARY_PATH}

    :/opt/IBM/db2/V9.5/lib64* at the node level of the slave. prior to installing this plugin, was able to access LB_LIBRARY_PATH value from the node when running the job (verified by echoing the value of the variable during the job run). After installing the plugin, can no longer access the value from the node, even though not using the "Prepare an environment for the run" section.

    To work around the issue, I needed to enable "Prepare an environment for the run" and then disable "Keep Jenkins Environment Variables" and "Keep Jenkins Build Variables"

  46. Unknown User (tpeguero)

    The scripting options look very useful, but I see no mention anywhere of what language is supported. What exactly is meant by "script" in this context?

  47. Unknown User (prithula)

    The EnvInject plugin still does not override the global environment variable in within a jenkins job. I am using version 1.89. 

    I have set couple of global variables in the jenkins. In one of the jenkins job, I am trying to override the values of those variables based on a condition. But it is not working.

    Below snippet is for reference:[EnvInject] - Loading node environment variables.
    [EnvInject] - Preparing an environment for the build.
    [EnvInject] - Keeping Jenkins build variables.
    [EnvInject] - Executing and processing the following script content: This piece is executed in the Prepare an environment for the run section.

    if [ $

    Unknown macro: {EmergencyFix}

    = true ]

    export RelPractice=$

    Unknown macro: {OldRelease}

    .x; export SprintCycle=""


    echo $

    Unknown macro: {RelPractice}

    [hudson] $ /bin/sh -xe /tmp/hudson3221881724786897823.sh
    + '[' true = true ']'
    + export RelPractice=1.4.x
    + RelPractice=1.4.x
    + export SprintCycle=
    + SprintCycle=
    + echo 1.4.x
    [EnvInject] - Script executed successfully.
    [EnvInject] - Injecting contributions.
    Building on master in workspace /var/lib/hudson/jobs/TestJob_Practice/workspace
    [EnvInject] - Executing scripts and injecting environment variables after the SCM step.
    [EnvInject] - Executing and processing the following script content: - This piece is executed in the Build environment section.

    echo $

    [workspace] $ /bin/sh -xe /tmp/hudson1726775335392935354.sh
    + echo 1.5
    1.5 - it is showing the old value.
    [EnvInject] - Script executed successfully.
    Finished: SUCCESS

  48. Unknown User (parkej60)

    I'm having an issue getting the BUILD_NUMBER to show up after I enable this functionality. I've check both of the options to 'Keep' jenkins variables. To be clear I'm setting '

    Provide version number and run avgtool' and entering a custom build number like so 0.1.12.$

    Unknown macro: {BUILD_NUMBER}

    1. Unknown User (parkej60)

      Actually never mind, this might be an issue with something else. 

  49. Unknown User (perun)

    I am looking for something like having set of jobs that will all share common environment variables. Is there anything like it for jenkins? I can't find anything like that?

    1. Unknown User (grayaii)

      Why not set them as global environment variables so that all your jobs can use it? http://stackoverflow.com/questions/19544535/jenkins-global-variables

  50. Unknown User (ciprian_vintea)

    I have a script which set up some variables for the build process (it should be sourced - Ubuntu OS). Using Script Content option, the variables are not available during the build process.Why?

    How can I add them to the build process?

  51. Unknown User (perun)

    Is it bug or feature that I cannot set Path variable from jenkins configuration?? I would like to do something like Path=$

    Unknown macro: {Path}

    ;C:\Program Files (x86)\Jenkins\Scripts.

    1. Unknown User (jminne)

      I am able to set the path like that.

  52. Unknown User (jminne)

    I just wanted to note for other people who are migrating from the deprecated SetEnv plugin to EnvInject that I ran into an issue with formatting.  The automatic migration did not work for me.  On a windows slave I had to convert from bash syntax to windows cmd syntax.

    SetEnv config:

    <localVarText>PATH=${PATH};C:\\Program\ Files (x86)\\MSBuild\\12.0\Bin</localVarText>

    Converted EnvInject config that didn't work:

    <propertiesContent>PATH=${PATH};C:\\Program\ Files (x86)\\MSBuild\\12.0\\Bin</propertiesContent>

    Working Envinject Config:

    <propertiesContent>PATH=$PATH;C:\Program Files (x86)\MSBuild\12.0\Bin</propertiesContent>
  53. Unknown User (ingo_at_jenkins)


    I have a short  question for this plugin.

    It has 2 main section in a job configuration:

    • Prepare an environment for the run
    • Inject environment variables to the build process

    These have the following subsections:

    • Properties File Path
      a file like contents in property contents
    • Properties Content
      # Dies ist ein Kommentar
      ! Dies ist ebenfalls ein Kommentar wenig Text
      pi = 3.14
      vieltext Dieser Text \
      läuft über zwei Zeilen.
      paramText = Text mit dynamischem Parameter:
      Unknown macro: {0}
      unicodeText = Ein Smiley: \u263A
    • Script File Path
      I have never used, but i think i can use batch-files as in the next section
      is the extension (*.bat, *.sh) fix or free?
    • Script Content
      I use batch contents like above
      echo %WORKSPACE%
      if "%WORKSPACE%"=="" exit 1
      but i have seen samples for shell script
      what is the used script language?
      Batch? Shell? is OS-depended Window=Batch an d linux=shell?
    • Evaluated Groovy script
      i have never used it so  I think grooy scripts will work

    Can anyone give me a clear information for the used script.

    Thank in Advance


  54. Unknown User (t3knoid)

    I am trying to use this to inject the version information from a pom.xml. I am doing this from a non-Maven job. I tried using this Groovy script to parse pom.xml. However, it appears that the job workspace is not the default folder. Can anyone shed some light on how to get the value of the workspace environment variable in this context:

    def pomFile = "pom.xml"
    try {
      pom = new XmlSlurper().parse(new File(pomFile))
    catch( ex ) {
      println "Unable to open: ${pomFile} - ${ex.class.name} : ${ex.message}"
    def version = [POM_VERSION: pom.version]
    return version
  55. Unknown User (ivan)

    I would like to add environment variables to “$JENKINS_URL/job/$JOB_NAME/$BUILD_ID/injectedEnvVars/",Is there any way?


    1. Plug-ins can not be used!Because I want to read real-time this environment variables.

    2. jenkins-cli.jar   set-env-variables [-s JENKINS_URL]  can not be used  !Because only in the next "Execute shell" to read, and can not be added to  “$JENKINS_URL/job/$JOB_NAME/$BUILD_ID/injectedEnvVars/".

    Is there any way?

  56. Unknown User (ivan)

    I would like to add environment variables to “$JENKINS_URL/job/$JOB_NAME/$BUILD_ID/injectedEnvVars/",Is there any way?


    1. Plug-ins can not be used!Because I want to read real-time this environment variables.

    2. jenkins-cli.jar   set-env-variables [-s JENKINS_URL]  can not be used  !Because only in the next "Execute shell" to read, and can not be added to  “$JENKINS_URL/job/$JOB_NAME/$BUILD_ID/injectedEnvVars/".

    Is there any way?

  57. Unknown User (alevinetx)

    Is there a way to silence the plugin so it doesn't display the script before executing it?EnvInject - Evaluation the following Groovy script content:
    def map = EnvInject Plugin
    ..... rest of my script source ....

    ... finally my script outputs, if any ...

    Thank you !

    1. Unknown User (oleg_nenashev)

      Please create the issue in Jenkins JIRA or vote for an existing one

  58. Unknown User (skyle143)

    I want to run this as a post-build action. Is that possible?

      1. Unknown User (clang)

        Unknown User (oleg_nenashev) I have both of those plugins installed as well as EnvInject, but when I add a "Flexible publish" as a post-build action, I don't see "Inject environment variables" as one of the available choices under "Add". Is there some additional configuration I'm missing in order to make this work?

  59. Unknown User (wardy277)

    In our deployment we use Git and have set "Additional Behaviours" → "Check out to a sub-directory" config. We have entered a Local subdirector and would like this available from a script/shell in the Build Section. Can this plugin achieve this?

  60. Unknown User (imurpalvicky)


            Can this be used in pipeline projects, My intention is i have pipeline project which gets the script files from the git using "Pipelinescriptfromscm", this checks out the github contents in master node . My git contents has properties file and few jenkins file. For some reason even after giving
    Properties File Path : pipeline.properties

    Properties Content : TESTENV=ENV1

    in my pipeline jenkins file i can access env.TESTENV but i cannot access the any properties in the pipeline.properties file.

               The same set up when i tried for the Free style project i could see the below logs but this is not happening for the pipeline jobs

    [EnvInject] - Executing scripts and injecting environment variables after the SCM step.

    [EnvInject] - Injecting as environment variables the properties file path 'pipeline.properties'

    [EnvInject] - Variables injected successfully.

    [EnvInject] - Injecting as environment variables the properties content


             So this plugin has any dissimilarities between pipeline job and freestyle job

    1. Unknown User (oleg_nenashev)

      See the EnvInject compatibility notice on this page. Pipeline is not fully supported

  61. Unknown User (holoadmin)

    Is it possible to add Comments?

    I'm configuring a a template job which other user later will copy.


    Lets say I have e.g.

    Properties content:



    Now in the template I would like to use comments, so something like

    UNITYVERSION="<Your Unity Version>"
    # Available Options are
    # "5.4"
    # "5.5"
    # "5.6"
    # "2017.1"
    # "2017.2"
    # "2017.3"
  62. Unknown User (saurabhsp)

    Can I give the groovy script file path instead of putting it in each of the job? and thus removing redundancy in system.

  63. Unknown User (martinjost)

    I have a security warning in Jenkins (2.114)  "Exposure of sensitive build variables stored by EnvInject 1.90 and earlier".

    We have the list of plugins and versions of them stored in SVN (updated daily) so I can find that we updated to 1.92.1 since at least end of Nov. 2015. I check using find, that I don't have any "injectedEnvVars.txt" on my master, older than this date.

    Still I get this error message. Can I silence it by solving the issue ? How ?
    Or do I simply need to disable the warning in Jenkins configuration ?
    (On one hand I don't  like to  just "click away" a security warning, on the other hand  an irrelevant warning is just clutter)



    1. Unknown User (holoadmin)

      Hi Martin,

      you can disable specific warnings under
      Manage Jenkins → Configure Global Security

      There should be a section "Hidden Security Warnings"
      Click on "Security Warnings"

      Now you should see a list with all current "permanent" security warnings you can enable and disable.

      1. Unknown User (martinjost)

        I just realized, that I ignore the specific warning - not all from this plugin. So yes, this is in my opinion a valid option. Just "clicked it away".

        Thanks for pushing me to this !


  64. Unknown User (algamil)

    I am trying to automate job duplication by using job's config.xml via jenkins cli. However, the resulting job has variables not properly entered in "Inject environment variables to the build process" like in example below. I am using v2.1.5 for environment injector.  

    1. Unknown User (algamil)

      Sorry I meant Jenkins API not CLI. So I am using curl to get the config.xml and to create new job using the slightly changed config.xml.

  65. Unknown User (dhoerner)

    Hi, after updating the Plugin to the latest version, our buildjobs fail.

    We're using the Plugin to configure our Pipeline-Projects.

    I have following Properties Content:


    And in the pipeline configuration, I check out the pipeline script with Perforce SCM. My Stream-Codeline is defined as ${DEPOT}/${STREAM}

    The pipeline script can not be checked out after the update. If I use //MyDepot/MyStream as Stream-Codeline all works as expected, so the variables can not be resolved any longer.