How can I retrieve environment variables(Jenkins) in java


I'm setting some environment variables by some windows batch commands in the pre-build steps for a Jenkins build. I need to use these variables for a few java selenium test cases which will run during as part of the build.

set HD_KF_TC_IN_LOOK_UP_KET_FEATURE_XLS = %WORKSPACE%\selenium_input_files\Key_Features\en_US

I have tried to retrieve these environment variable values by using System.getEnv(HD_KF_TC_IN_LOOK_UP_KET_FEATURE_XLS) commands. But this is not working as the values for these variables is always NULL.

Please let me know where I'm I going wrong?


As indicated in my comment, I do not completely understand your setup. In general, however, environment variables set in one Jenkins build step do not propagate outside of it and can't be accessed from other build steps. You need to use <a href="https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin" rel="nofollow">EnvInject plugin</a> to achieve that.


  • Can't update data from sonarqube server
  • Azure Log analytics : Error while configuring custom data
  • How to compare type symbols (ITypeSymbol) from different projects in Roslyn?
  • gulp command not recognized in Jenkins
  • Maven LifeCycleExecutor with an incomplete configuration error
  • redux-thunk with typescript
  • How can i use script in sub folders on gae?
  • How do you disable Android Library Update?
  • BeautifulSoup not working, getting NoneType error
  • Template is missing error even if I have done a redirect_to in the controller
  • Gradle failed to build with error Multiple dex files define
  • Deploying Tizen app to Gear S2: Non trusted certificate is used
  • Selenium Firefox WebDriver in WCF throwing “failed to start up socket within 45000 ms”
  • How do I retrieve the text in a table column using Selenium RC?
  • How to capture or listen to browser notifications?
  • Gradle test fails with NullPointerException
  • Can you use multiple instances of Edge on a Selenium Grid Node?
  • How to import Navit into Eclipse and use it in own android project
  • Mapping two workspace folders to the same working directory
  • Why isn't my “Fizz Buzz” test in R working?
  • crash in __tcf_0
  • For loop with if condition on multiple R functions
  • Selenium to click on a javascript button corresponding to a text
  • Content-Length header not returned from Pylons response
  • Python urlparse: small issue
  • OpenGL ES texture problem, 4 duplicate columns and horizontal lines (Android)
  • Display issues when we change from one jquery mobile page to another in firefox
  • Deselecting radio buttons while keeping the View Model in synch
  • Cross-Platform Protobuf Serialization
  • Perl system calls when running as another user using sudo
  • JSON with duplicate key names losing information when parsed
  • Jquery - Jquery Wysiwyg return html as a string
  • SVN: Merging two branches together
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • How to format a variable of double type
  • PHP: When would you need the self:: keyword?
  • coudnt use logback because of log4j
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • JaxB to read class hierarchy