How to Create a Jenkins Job that Reads and Prints Environment Variables During a Build?
Share
Condition for Create a Jenkins Job that Reads and Prints Environment Variables During a Build
Description: Jenkins automatically provides several environment variables during a build, such as $JENKINS_HOME, $WORKSPACE, and $BUILD_NUMBER. These variables help you identify the Jenkins home directory, the job workspace, and the build number. By printing them in a job, you can verify the environment setup and use these variables in scripts or pipelines.
Steps
Step 1 — Open Jenkins Dashboard
Go to your browser and enter your Jenkins URL, e.g., http://localhost:8080
Step 2 — Create a New Job
Click New Item on the left menu
Enter Job Name: env-test
Select Freestyle Project → Click OK
Step 3 — Add a Build Step
Scroll to the Build section
Click Add build step → Execute shell
Step 4 — Enter Shell Script
In the shell command box, type: