If you are playing with Jenkins, one of the first things that you might be asking yourself is how to get the default Jenkins environment variables. It’s simple and easy, so let’s jump to the Solution part.
Step 1. The easiest way to obtain the Jenkins environment variables is the Jenkins env variables html page.
If Jenkins is installed locally:
Step 2. To get specific environment variables you can create a new Jenkins job, by selecting the
Execute shell in the ` Build` section.
echo "BUILD_ID" :: $BUILD_ID echo "BUILD_NUMBER" :: $BUILD_NUMBER echo "BUILD_TAG" :: $BUILD_TAG echo "BUILD_DISPLAY_NAME" :: $BUILD_DISPLAY_NAME echo "EXECUTOR_NUMBER" :: $EXECUTOR_NUMBER echo "JOB_NAME" :: $JOB_NAME echo "JOB_BASE_NAME" :: $JOB_BASE_NAME echo "JENKINS_HOME" :: $JENKINS_HOME echo "JENKINS_URL" :: $JENKINS_URL echo "NODE_NAME" :: $NODE_NAME echo "NODE_LABELS" :: $NODE_LABELS echo "WORKSPACE" :: $WORKSPACE
Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.