Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Environment variables in Jenkins

Tags:

jenkins

Where do the environment variables under Jenkins ( manage jenkins -> system information ) come from?

I checked /etc/init.d/tomcat5, /usr/bin/dtomcat5, /usr/bin/tomcat5, /etc/sysconfig/tomcat5 and /etc/profile but do not see any such variables there specially the ones related to Oracle (Base, Home, Ld_lib, path, etc.). Tomcat's bashrc has some oracle related variables which I commented out but I still see the same in the jenkins system info page. Any directions?

like image 773
f-z-N Avatar asked Jan 15 '14 06:01

f-z-N


People also ask

Where are environment variables in Jenkins?

Via env-vars. The environment variables can be viewed on an HTML page. You have to open the page on your Jenkins controller server. The steps to view the jenkins environment variables list are : At the address bar of chrome, type ${YOUR_JENKINS_HOST}/env-vars.

How do you set an environment variable in Jenkins pipeline?

Setting Stage Level Environment Variable It is by using the env variable directly in the script block. We can define, let us say, USER_GROUP and display it. You will see that the underlying shell also has access to this environment variable. You can also set an environment variable using withEnv block.

What is inject environment variables in Jenkins?

Injects environment variables at node (master/agent) 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. Securely injects password values for a run.


3 Answers

The environment variables displayed in Jenkins (Manage Jenkins -> System information) are inherited from the system (i.e. inherited environment variables)

If you run env command in a shell you should see the same environment variables as Jenkins shows.

These variables are either set by the shell/system or by you in ~/.bashrc, ~/.bash_profile.

There are also environment variables set by Jenkins when a job executes, but these are not displayed in the System Information.

like image 193
Alex Bitek Avatar answered Nov 09 '22 16:11

Alex Bitek


What ultimately worked for me was the following steps:

  1. Configure the Environment Injector Plugin
  2. Goto to the /job/<project>/configure screen
  3. In "Build Environment" section check "Inject environment variables to the build process"
  4. In "Properties Content" specified: TZ=America/New_York
like image 38
Farrukh Najmi Avatar answered Nov 09 '22 17:11

Farrukh Najmi


The quick and dirty way, you can view the available environment variables from the below link.

http://localhost:8080/env-vars.html/

Just replace localhost with your Jenkins hostname, if its different

like image 16
vkrams Avatar answered Nov 09 '22 16:11

vkrams