Problems with Env Variables

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problems with Env Variables

Marcelo Brunken
Hello,

I just found out a very evil bug in Jenkins, I need to access a env variable, that I set on the global jenkins config, it runs okay when I use build.getEnvironment(launcher.getListener()),
The build instance come direct from the overrided method signature, every seems ok, here a print of the variables key set.

[_, AUTH_DIR, BUILD_ID, BUILD_NUMBER, BUILD_TAG, BUILD_URL, CATALINA_BASE, CATALINA_HOME, CATALINA_OPTS, CATALINA_PID, CLASSPATH, EXECUTOR_NUMBER, FLEX_HOME, GREP_OPTIONS, HOME, HUDSON_HOME, HUDSON_SERVER_COOKIE, HUDSON_URL, JAVA_HOME, JAVA_OPTS, JENKINS_HOME, JENKINS_SERVER_COOKIE, JENKINS_URL, JOB_NAME, JOB_URL, KRB5CCNAME, LANG, LANGUAGE, LD_LIBRARY_PATH, LESSCLOSE, LESSHISTFILE, LESSOPEN, LOGNAME, LS_COLORS, LS_OPTIONS, MAIL, MAILTO, NLSPATH, NODE_LABELS, NODE_NAME, PATH, PWD, REALUSER, SHELL, SHLVL, SVN_SSH, TERM, TZ, USER, WORKSPACE, XFILESEARCHPATH]

The AUTH_DIR variable was set on Jenkins config.

The problem is, I need to run that build.getEnvironment(launcher.getListener()) on another method, that has not the build on the signature, but the project,
so I simply use project.getLastBuild(), (it is failsafe, it will always have a last build)

so what comes back is

[_, BUILD_ID, BUILD_NUMBER, BUILD_TAG, BUILD_URL, CATALINA_BASE, CATALINA_HOME, CATALINA_OPTS, CATALINA_PID, CLASSPATH, GREP_OPTIONS, HOME, HUDSON_HOME, HUDSON_SERVER_COOKIE, HUDSON_URL, JAVA_HOME, JAVA_OPTS, JENKINS_HOME, JENKINS_SERVER_COOKIE, JENKINS_URL, JOB_NAME, JOB_URL, KRB5CCNAME, LANG, LANGUAGE, LD_LIBRARY_PATH, LESSCLOSE, LESSHISTFILE, LESSOPEN, LOGNAME, LS_COLORS, LS_OPTIONS, MAIL, MAILTO, NLSPATH, PATH, PWD, REALUSER, SHELL, SHLVL, SVN_SSH, TERM, TZ, USER, WORKSPACE, XFILESEARCHPATH]

my variable is missing, so bad errors happen after, is this a bug or a normal behavior ? how can I overcome this, is there a better way to get Global Env Variables ?

Thanks!