it:ad:jenkins:howto:work_with_the_environment_variables

IT:AD:Jenkins:HowTo:Work with the Environment Variables

As already expressed in the IT:AD:Jenkins:Glossary, each time Jenkins starts a new Build it copies into the shell the normal system Environment Variables/, but also a sets a couple of custom temporary ones (they will be lost when the Build process completes) that are unique to that build.

The following basic environment fields are always available to shell scripts, but additional Plugins can define others.

  • BUILDNUMBER: The current build number, such as “153” * BUILDID: The current build id, such as “2005-08-2223-59-59” (YYYY-MM-DDhh-mm-ss)
  • JOBNAME: Name of the project of this build, such as “foo” or “foo/bar” * BUILDTAG: String of “jenkins-${JOBNAME}-${BUILDNUMBER}”. Convenient to put into a resource file, a jar file, etc for easier identification.
  • EXECUTORNUMBER: The unique number that identifies the current executor (among executors of the same machine) that's carrying out this build. This is the number you see in the “build executor status”, except that the number starts from 0, not 1. * NODENAME: Name of the slave if the build is on a slave, or “master” if run on master
  • NODELABELS: Whitespace-separated list of labels that the node is assigned. * WORKSPACE:The absolute path of the directory assigned to the build as a workspace. * JENKINSHOME: The absolute path of the directory assigned on the master node for Jenkins to store data.
  • JENKINSURL: Full URL of Jenkins, like http://server:port/jenkins/ * BUILDURL: Full URL of this build, like http://server:port/jenkins/job/foo/15/
  • JOB_URL: Full URL of this job, like http://server:port/jenkins/job/foo/</sxh>

More can be seen here:

An example of usage: * IT:AD:Jenkins:HowTo:Invoke a PreBuild Batch Command

  • /home/skysigal/public_html/data/pages/it/ad/jenkins/howto/work_with_the_environment_variables.txt
  • Last modified: 2023/11/04 01:46
  • by 127.0.0.1