EnvInject Plugin

Skip to end of metadata
Go to start of metadata

Plugin Information

Plugin ID envinject Changes In Latest Release
Since Latest Release
Latest Release
Latest Release Date
Required Core
Dependencies
1.89
Oct 13, 2013
1.445
maven-plugin (version:1.445)
ivy (version:1.21, optional)
Source Code
Issue Tracking
Maintainer(s)
GitHub
Open Issues
Gregory Boissinot (id: gbois)
Usage Installations 2013-Apr 6452
2013-May 7037
2013-Jun 7679
2013-Jul 8400
2013-Aug 8918
2013-Sep 9464
2013-Oct 10365
2013-Nov 10780
2013-Dec 11073
2014-Jan 12104
2014-Feb 12837
2014-Mar 13796

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

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

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
  • 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 coma separated list:

BUILD_CAUSE=USERIDCAUSE, SCMTRIGGER, UPSTREAMTRIGGER 

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

BUILD_CAUSE_USERIDCAUSE=true
BUILD_CAUSE_SCMTRIGGER=true
BUILD_CAUSE_UPSTREAMTRIGGER=true

Configuration

At node (master and slaves) 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
$JENKINS_HOME/jobs/<your_job>/builds/<your_build>.

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

Examples

Append to PATH on Windows

Gerrit Trigger plugin with parameterized Build branch name

  • Check "This build is parameterized"
    • Name: GERRIT_BRANCH
    • 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

  • with the MaskPasswords 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.
  • with 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

  • Properties values can't end with backslashes in the properties content section
    (interpreted as content with multiple lines)
  • 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 otehr 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.

Jenkins core compatibility

This plugin requires Jenkins 1.444+

TODO LIST (Enhancement)

  • Priority Critical: Add tests (unit tests and integration tests)
  • Priority Important: Provide an abstraction layer for manipulating easier the environment variables
    • Provide a custom lifecycle during the job flow
    • Sort these variables
    • Break down into categories, etc

Note: Any contributions are welcome.
Feel free to fork the source code and provide a pull request

Changelog

1.88

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

1.87

* Actually load script from master

1.86

* Fix reopen issue #13348 - EnvInject overriding WORKSPACE variable

1.85

* Retain line break characters in property values.

1.84

* Add logger to Groovy script evaluation

1.83

* Fix reopen issue #16316 - Global variables not updated

1.82

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

1.81

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

1.80

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

1.79

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

1.78

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

1.77

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

1.76

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

1.75

* Add currentJob and currentBuild variables for Groovy scripts

1.74

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

1.73

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

1.72

* Fix issue #15146 - EnvJect unsets empty string properties returned in maps

1.71

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

1.70

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

1.69

* Fix issue #14930 - Can't overload/update PYTHONPATH

1.68

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

1.67

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

1.66

* Fix issue #14686 - Fail evaluating Groovy script before job run

1.65

* Add feature - Mask job password parameter value

1.64

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

1.63

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

1.62

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

1.61

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

1.60

* Fix issue #14290 - Support for Ivy project type

1.59

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

1.58

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

1.57

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

1.56

* 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

1.55

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

1.54

* A few minor changes to keep jdk5 compatibility

1.53

* Fix regression on backward compatibility

1.52

* Remove env variables presence in build serialization file

1.51

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

1.50

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

1.49

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

1.48

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

1.47

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

1.46

* Fix interaction with multijob plugin

1.45

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

1.44

* Fix EnvInject Password process

1.43

* Fix reopened issue #12108 - EnvInject failure using multi-configuration jobs

1.42

* Fix issue #13183 - SCM variables resolution

1.41

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

1.40

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

1.39

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

1.38

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

1.37

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

1.36

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

1.35

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

1.34

* Change Environment contributors resolution

1.33

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

1.32

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

1.31

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

1.30

* Fix issue #12905 - PATH variable is not injected

1.29

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

1.28

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

1.27

* Add a build context to EnvInjectContributor

1.26

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

1.25

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

1.24

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

1.23

* Fix issue #12788 - Missing variables when executing EnvInject script

1.22

* Fix NullPointerException for a setenv or a envfile migration

1.21

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

1.20

* 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

1.19

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

1.18

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

1.17

* Fix migration from the setenv and envfile plugin

1.16

* Fix external EnvInjectContribution section display
* Fix text typo

1.15 (technical release)

* Refactoring + fix wrong commit

1.14

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

1.13

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

1.12

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

1.11

* Update to envinject-lib 1.2

1.10

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

1.9

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

1.8

* Switch properties section and scripts section for the prepare step

1.7

* Fix issue #12293 - Incorrect inserting environment variables on linux slave

1.6

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

1.5

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

1.4

* 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)

1.3

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

1.2

* Fix NullPointerException when master has 0 executors

1.1

* Fix issue #12108 - EnvInject failure using multi-configuration jobs
* Fix issue #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

1.0

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

0.26

* Enhance display log
* Refactoring for fixing properties variables propagation

0.25

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

0.24

* Make it extensible by an another plugin.

0.23

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

0.22

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

0.21

* Add global properties and node properties process

0.20

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

0.19

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

0.18

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

0.17

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

0.16

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

0.15

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

0.14

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

0.13.1

* Improve reporting errors

0.13

* Fix issue #10919 - Variables are shared between jobs

0.12

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

0.11.1 (technical release)

* Remove unused maven dependency

0.11

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

0.10

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

0.9

* Fix partially issue #10847 and issue #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).

0.8

* Fixed variables restauration for Maven jobs

0.7

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

0.6

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

0.5

* Remove advanced sections

0.4

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

0.3

* Add variables resolution in elements

0.2.1

* Fix environment script content process

0.2

* Can inject environment variables as a build step.

0.1

* Initial version

Labels

plugin-buildwrapper plugin-buildwrapper Delete
plugin-builder plugin-builder Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Aug 04, 2011

    Erick Dovale says:

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

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

    1. Aug 04, 2011

      Gregory Boissinot says:

      Thanks for your suggestion. Done.

      Thanks for your suggestion.
      Done.

  2. Aug 10, 2011

    Erick Dovale says:

    Awesome plugin!!!!

    Awesome plugin!!!!

  3. Aug 24, 2011

    Andy Hitchman says:

    Is it possible to substitute in existing env vars? Like: TEST_DATABASE=UnitTe...

    Is it possible to substitute in existing env vars?

    Like:

    TEST_DATABASE=UnitTest-$(BUILD_TAG)
    
    

    We're installed on W2K8

    1. Aug 25, 2011

      Gregory Boissinot says:

      Yes it is possible to substitute environment variables in text value. However, $...

      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. Aug 29, 2011

        Leo von Klenze says:

        Hello, I tried that with ${WORKSPACE} . Unfortunately I'm bound to a windows b...

        Hello,

        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. Aug 29, 2011

          Gregory Boissinot says:

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

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

          1. Aug 30, 2011

            Leo von Klenze says:

            Sure! I wrote the following to properties content: TEST_OUTPUT=${WORKSPA...

            Sure!

            I wrote the following to properties content:

            TEST_OUTPUT=${WORKSPACE}\\test
            

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

            Unfortunately the following value is injected:

            d:jenkinsjobs...
            

            instead of

            d:\jenkins\jobs\...
            

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

            TEST_OUTPUT=D:\jenkins\jobs\...
            

            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. Aug 25, 2011

    Jason Swager says:

    There seems to be a problem with this plugin.  When values are injected as ...

    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. Aug 25, 2011

      Gregory Boissinot says:

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

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

      1. Aug 26, 2011

        Jason Swager says:

        Waiting for v0.7 with bated breath...  If it does work, this will make my j...

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

        1. Aug 29, 2011

          Leo von Klenze says:

          Hi, does not work for me. Environmental variables are still spreading to other ...

          Hi,

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

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

          Thanks!

          1. Aug 29, 2011

            Gregory Boissinot says:

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

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

      2. Aug 29, 2011

        Hizuya Atsuzaki says:

        I used version 0.7.  When the job with 'Keep System Environment Variables' ...

        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. Aug 29, 2011

          Gregory Boissinot says:

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

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

          1. Aug 30, 2011

            Hizuya Atsuzaki says:

            hm. My master node's "# of executors" is "0". There are two slave node, wh...

            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. Aug 30, 2011

              Gregory Boissinot says:

              Could you raise an issue with screenshot and your job configuration file (config...

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

              1. Aug 30, 2011

                Hizuya Atsuzaki says:

                OK.  Please see JENKINS-10845. Thanks!

                OK.  Please see JENKINS-10845.

                Thanks!

  5. Sep 01, 2011

    Jason Swager says:

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

    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. Sep 04, 2011

      Gregory Boissinot says:

      In all the cases, i strongly recommand to check if a variable is set before exec...

      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. Sep 05, 2011

        jswager - says:

        Yeah - I can see checking all variables.  It just comes as a bit of shock w...

        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. Sep 02, 2011

    Bogdan Iosif says:

    It would be very useful if the user could add env vars defined in a file BUT ALS...

    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. Sep 02, 2011

      Jason Swager says:

      At least for me, any file that I use is generated during the build.  So bei...

      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. Sep 04, 2011

      Gregory Boissinot says:

      The plugin already enables you to provide variables in the job configuration UI ...

      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. Sep 05, 2011

        Bogdan Iosif says:

        I fully understand the current functionality. What I was requesting is something...

        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. Sep 05, 2011

          Gregory Boissinot says:

          OK, If I understand, you want Jenkins to provide for example a link to display o...

          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. Sep 05, 2011

            Bogdan Iosif says:

            Done, https://issues.jenkins-ci.org/browse/JENKINS-10899 Thank you very much fo...

            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. Sep 19, 2011

    Luis Piedra-Márquez says:

    Hi, I've trying EnvInject plugin, but I've found one problem. I'm developing a ...

    Hi,

    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?

    Regards,

       Luis Piedra

      

    1. Sep 19, 2011

      Gregory Boissinot says:

      You can access latest injected environment variables by the following URL <je...

      You can access latest injected environment variables by the following URL
      <jenkins_url>/<job>/lastBuild/injectedEnvVarResust.

      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. Sep 29, 2011

    pixman20 says:

    Only version 0.15 is available in the Jenkins Update Center. What needs to be d...

    Only version 0.15 is available in the Jenkins Update Center.

    What needs to be done to make 0.18 available?

    Thanks!

    1. Sep 29, 2011

      Gregory Boissinot says:

      Maybe an update center problem with your infrastructure. Please send a message t...

      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. Oct 25, 2011

    Jesse J says:

    It doesn't seem like this plugin might have a problem with multi-config projects...

    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. Oct 29, 2011

      Gregory Boissinot says:

      Please could raise an issue?

      Please could raise an issue?

  10. Oct 28, 2011

    Jean-Luc Pinardon says:

    Well, very interesting "unifying" plugin. Thanks. But... I would like to inject ...

    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.
    J.L.P.

    1. Dec 07, 2011

      Gregory Boissinot says:

      The EnvInject plugin is not only an aggregation of the sentenv and the envfile p...

      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. Aug 29, 2013

        Todd Orr says:

        I think there's been a regression here. I'm attempting to use values set during...

        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
        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. Dec 02, 2011

    Roger Myung says:

    I really like the way this plugin works, thanks! There are a few things I'v...

    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. Dec 07, 2011

      Gregory Boissinot says:

      Thanks for using the plugin. 1) Did you try $PATH or ${PATH}? 2) Could you try t...

      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. Dec 06, 2011

        Roger Myung says:

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

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

        The new version fixed the second problem, thanks! 

        1. Dec 07, 2011

          Gregory Boissinot says:

          Thanks. I'll update your issue.

          Thanks.
          I'll update your issue.

  12. Jan 03, 2012

    juraj fedorko says:

    Hi, I have problem with new plugin 1.5/1.6 (1.2 works well) on slave (linux) no...

    Hi,

    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. Jan 03, 2012

      Gregory Boissinot says:

      Could raise a bug report in the Jenkins issue tracker?

      Could raise a bug report in the Jenkins issue tracker?

  13. Jan 03, 2012

    Peter Sukhenko says:

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

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

    1. Jan 04, 2012

      Gregory Boissinot says:

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

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

      1. Jan 04, 2012

        Peter Sukhenko says:

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

        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.

        Thanks

        1. Jan 04, 2012

          Gregory Boissinot says:

          Fixed in 1.7.

          Fixed in 1.7.

          1. Jan 05, 2012

            Peter Sukhenko says:

            Confirmed

            Confirmed

    2. Jan 05, 2012

      Gregory Boissinot says:

      Does the problem persist with EnvInject 1.7?

      Does the problem persist with EnvInject 1.7?

  14. Jan 05, 2012

    Patrick Renaud says:

    First, many tx for this plugin as it solves an issue I had with having the envir...

    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?

    Tx.

    1. Jan 06, 2012

      Gregory Boissinot says:

      As a build step, you can execute a script creating a properties file and then in...

      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. Jan 06, 2012

        Roger Myung says:

        I'd love this feature too.. I'm specifically looking at the case of mapping a dr...

        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. Jan 09, 2012

          Gregory Boissinot says:

          Please could you try the version 1.8? Execute a script executing your mapping dr...

          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. Jan 15, 2012

    Frederic Latour says:

    Hi, I don't know if it's easy or not (or even impossible) but one great additio...

    Hi,

    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. Jan 16, 2012

      Gregory Boissinot says:

      In my opinion, a job has to be executed in isolation from other jobs. Therefore,...

      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. Jan 23, 2012

    Patrick Renaud says:

    During a Release build (via the Release plugin) I need to run additional steps w...

    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. Jan 26, 2012

      Gregory Boissinot says:

      I'll add this feature as soon as possible

      I'll add this feature as soon as possible

      1. Jan 29, 2012

        Gregory Boissinot says:

        I made a new plugin for this feature: the shared objects plugin. This plugin mak...

        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. Jan 31, 2012

    Sherrie Ma says:

    Thanks a lot for the great tool!

    Thanks a lot for the great tool!

  18. Feb 07, 2012

    Patrick Renaud says:

    Is it possible that the variables aren't injected at post-build time when Sonar ...

    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. Feb 10, 2012

      Gregory Boissinot says:

      Could you raise a bug report in the issue tracker and attach your job configurat...

      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. Feb 10, 2012

    Natalia Naumova says:

    Hi!  I have master/slave setup, and my project has the ability to exec...

    Hi! 

    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

     
    ${JENKINS_HOME/workspace/${JOB_NAME}
    ${JENKINS_HOME/workspace/${JOB_NAME}@2
    ${JENKINS_HOME/workspace/${JOB_NAME}@3
    ...
    

    But $WORKSPACE always points to

     
    ${JENKINS_HOME/workspace/${JOB_NAME}
    

    for all jobs

    1. Feb 10, 2012

      Gregory Boissinot says:

      Ok thanks for raising this issue. The issue is able to keep track of in the iss...

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

    2. Feb 24, 2012

      Walter Kacynski says:

      I'm not sure how the variable is handled but I don't have "'Execute concurrent b...

      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. Feb 26, 2012

        Gregory Boissinot says:

        Strange behavior! With Envinject 1.28, the plugin does not compute the workspace...

        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?

        Thanks

        1. Feb 27, 2012

          Walter Kacynski says:

          OK, I posted my comment before I saw that 1.28 is available.  I have update...

          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. Feb 27, 2012

    Natalia Naumova says:

    Hi again!  With 1.29 update $PATH variable is not redefined:  co...

    Hi again! 

    With 1.29 update $PATH variable is not redefined: 

    console: 

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

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

    1. Feb 27, 2012

      Gregory Boissinot says:

      Fixed in 1.30

      Fixed in 1.30

  21. Feb 28, 2012

    Magnus Ericmats says:

    Can I use this plugin to inject a variable containing downstream jobs, which I c...

    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. Feb 29, 2012

      Gregory Boissinot says:

      I don't know if there is a variable referencing the downstream job (maybe provid...

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

  22. Feb 28, 2012

    Walter Kacynski says:

    Is it possible to hide values from the "Injected Environment Variables" section ...

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

    1. Feb 28, 2012

      Walter Kacynski says:

      I might have answered my own question with https://issues.jenkins-ci.org/browse/...

      I might have answered my own question with https://issues.jenkins-ci.org/browse/JENKINS-12423

      1. Feb 29, 2012

        Gregory Boissinot says:

        Yes. You can't use mask-passwords plugin and envinject plugin together. However,...

        Yes.
        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. Feb 29, 2012

          Walter Kacynski says:

          Darn, I need to use mask passwords because username/passwords need to be defined...

          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. Mar 04, 2012

            Gregory Boissinot says:

            Waiting for the add of password per job, you can use password parameters given t...

            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. Mar 04, 2012

            Gregory Boissinot says:

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

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

            1. Mar 06, 2012

              Walter Kacynski says:

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

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

  23. Mar 19, 2012

    Alex Gray says:

    How do you roll back to a previous version of this plugin?  We were at 1.3...

    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.

    Thanks.

    1. Mar 20, 2012

      Gregory Boissinot says:

      To uninstall the plugin: a) Stop the Jenkins instance b) Go to $JENKINS_HOME/plu...

      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. Mar 20, 2012

    Oleksandr Popov says:

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

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

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

    1. Mar 22, 2012

      Gregory Boissinot says:

      Issue fixed.

      Issue fixed.

  25. Mar 20, 2012

    Christopher Stephens says:

    I'm having trouble getting the P4_CHANGELIST variable. It appears that the varia...

    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} 
    144219
    1. Mar 22, 2012

      Gregory Boissinot says:

      Do you know which plugin provides this variable? Please could you report a bug a...

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

      1. Mar 29, 2012

        Christopher Stephens says:

        This is from the perforce plugin, however it looks like as of version 1.44 this ...

        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 =)

        Thanks!

  26. Mar 28, 2012

    Chris Rankin says:

    We just tried using the EnvInject plugin to set a computed environment variable ...

    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. Mar 28, 2012

      Gregory Boissinot says:

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

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

      1. Mar 29, 2012

        Chris Rankin says:

        I don't have access to the XML configuration for the particular failing job, alt...

        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. Mar 29, 2012

          Gregory Boissinot says:

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

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

          1. Mar 29, 2012

            Chris Rankin says:

            We've just upgraded to the latest version of Jenkins (from 1.443), and will need...

            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. Mar 31, 2012

              Gregory Boissinot says:

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

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

  27. Jun 13, 2012

    Bruce Edge says:

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

    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:

    APP1_ARTIFACTS=source/path/app/lib/*/,source/path/app/target/*.war,source/path/app/src/main/scripts/*

    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. Jun 14, 2012

      Bruce Edge says:

      Never mind, figured it out. One of the paths was wrong. It's difficult to tell ...

      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. Jun 26, 2012

    Mike Harris says:

    I'm trying to use a properties file with a single key which has it's values spre...

    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. Jun 27, 2012

      Gregory Boissinot says:

      Could you report a bug in the Jenkins issue tracker for the envinject and parame...

      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. Jul 23, 2012

    Brandon Pancost says:

    I've been setting up a number of builds that require different path environment ...

    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. Aug 09, 2012

      Gregory Boissinot says:

      At the moment, it is not possible to source a file. Therefore, set the path in a...

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

  30. Aug 17, 2012

    Neven Luetic says:

    I defined a Groovy script in "Prepare environment for run" to set some environme...

    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. Aug 18, 2012

      Gregory Boissinot says:

      At the moment, Envinject plugin doesn't work for a job type of Build flow. This ...

      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. Aug 23, 2012

        jaron Sampson says:

        @Neven - I use freestyle jobs with the Build Pipeline Plugin to create "flows" -...

        @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. Aug 24, 2012

          Gregory Boissinot says:

          I don't know if the EnvInject plugin is compatible with the Build Pipeline plugi...

          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. Aug 27, 2012

            jaron Sampson says:

            So far, so good. I am passing a gitish along the pipeline and building from a de...

            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. Sep 13, 2012

              Neven Luetic says:

              Been away for a while ... Trying to represent my job pipeline with Build Pipeli...

              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. Sep 16, 2012

                Gregory Boissinot says:

                It's not an issue of your configuration. At the moment, it is only an issue betw...

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

                1. Sep 17, 2012

                  Neven Luetic says:

                  Like I said: it's BuildPipeline this time.

                  Like I said: it's BuildPipeline this time.

      2. Sep 17, 2012

        Nicolas De Loof says:

        #troll Envinject uses a white-list for supported job types, any plugin to d...

        #troll

        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 

        #/troll

        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. Aug 17, 2012

    lionel alberti says:

    Hello, We're using Config File Provider which sets an environment variable to t...

    Hello,

    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. Aug 23, 2012

      Gregory Boissinot says:

      Track with JENKINS-14897

      Track with JENKINS-14897

  32. Sep 05, 2012

    Alex Dover says:

    I'm trying to use a combination of parameterized build and envinject and I've ru...

    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?

    Thanks.

    1. Sep 05, 2012

      Gregory Boissinot says:

      Jenkins enables you to define build parameter with spaces. However, I think it i...

      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. Feb 04, 2013

    Walter Kacynski says:

    Where can I find the published Javadocs for this plugin?  I'm trying to wri...

    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. Feb 10, 2013

      Gregory Boissinot says:

      The jar of source code can be found here http://maven.hudson-labs.org:8081/conte...
  34. Mar 01, 2013

    Ramón Rial says:

    Is there a way with a groovy script to return variables which should be consider...

    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:

    user=username
    
    password=password_of_the_user
    

    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.

    user=username
    
    encrypted.password=password_of_the_user
    

    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. Mar 11, 2013

      Gregory Boissinot says:

      It could be a great idea. However, I have difficulty implementing this new featu...

      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. Apr 12, 2013

    Jon Starbird says:

    I'm using the Job Exporter plugin which dumps another job's Env Variables into a...

    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

    $build.number
    
    ${build.number}
    
    ${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. Apr 14, 2013

      Gregory Boissinot says:

      Job Exporter plugin provides a properties file where property name contains a '....

      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. Apr 16, 2013

        Jon Starbird says:

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

        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.

        Thanks,

        Jon

  36. Apr 17, 2013

    Andrew C says:

    Quick question: For "Properties File Path" I'd like to be able to refer to a bui...

    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:

    /jenkins/$SlaveOS.properties
    
    /jenkins/${SlaveOS}.properties
    
    /jenkins/%SlaveOS%.properties
    
  37. May 13, 2013

    Louis Roché says:

    In many builds, I have randomly this error EnvInject - Loading node envir...

    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. May 15, 2013

    Andrew C says:

    Quick question: Does Evaluated Groovy script run on the Jenkins master or on the...

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

  39. May 28, 2013

    Wael Darwich says:

    Hi, I am using EnvInject 1.85 with Jenkins ver. 1.512 and I found that whe...

    Hi,

    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. Jun 05, 2013

      Wael Darwich says:

      Gregory, Thanks a lot, I see you already started working on 1.86, you are a sta...

      Gregory,

      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. May 29, 2013

    Wael Darwich says:

    Gregory, I've tested the new 1.86 and it is the same as 1.85, I still cannot se...

    Gregory,

    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

    Regards

  41. Jun 05, 2013

    Wael Darwich says:

    Gregory, I've tested the new 1.87 using Jenkins ver. 1.512 and restarted b...

    Gregory,

    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

    Regards

  42. Jul 04, 2013

    Sven Delmas says:

    I hope this is the appropriate way to report an issue (if not, please tell me an...

    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. Jul 07, 2013

      Sven Delmas says:

      Upgrading to 1.522 fixed the issue.

      Upgrading to 1.522 fixed the issue.

  43. Sep 16, 2013

    Arpit Nagar says:

    Hi, We are getting issue in retrieving Global Password Field. Steps to reprodu...

    Hi,

    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.

    Thanks

    Arpit Nagar

  44. Sep 18, 2013

    Neven Luetic says:

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

    Hello,

    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.

    --

    Thanks

    Neven

  45. Oct 25

    Alex Rodrigues says:

    Specifications of environment master (Jenkins server) installed on Red Hat Enter...

    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. Dec 22

    Tony Peguero says:

    The scripting options look very useful, but I see no mention anywhere of what la...

    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. Dec 30

    Prithula Mukherjee says:

    The EnvInject plugin still does not override the global environment variable in ...

    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 ]

    then
    export RelPractice=$

    Unknown macro: {OldRelease}

    .x; export SprintCycle=""

    fi

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