0
0
Jenkinsdevops~10 mins

Environment variables access in Jenkins - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to access the environment variable named 'HOME' in a Jenkins pipeline.

Jenkins
echo "Home directory is: $[1]"
Drag options to blanks, or click blank then click option'
AHOME_DIR
Bhome
Cenv.HOME
DHOME
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase variable names like $home
Using incorrect syntax like env.HOME without proper context
2fill in blank
medium

Complete the code to print the environment variable 'BUILD_NUMBER' inside a Jenkins pipeline script.

Jenkins
echo "Build number is: $[1]"
Drag options to blanks, or click blank then click option'
ABUILD_NUMBER
Benv.BUILD_NUMBER
Cbuild_number
DBuildNumber
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase variable names
Trying to access variables as env.BUILD_NUMBER without proper syntax
3fill in blank
hard

Fix the error in accessing the environment variable 'PATH' in this Jenkins pipeline snippet.

Jenkins
echo "System path: $[1]"
Drag options to blanks, or click blank then click option'
APATH
Bpath
Cenv.PATH
D$PATH
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'env.PATH' which is not valid in shell steps
Using lowercase 'path' which is not recognized
4fill in blank
hard

Fill both blanks to correctly access environment variables 'USER' and 'WORKSPACE' in a Jenkins pipeline script.

Jenkins
echo "User: $[1], Workspace: $[2]"
Drag options to blanks, or click blank then click option'
AUSER
Buser
CWORKSPACE
Dworkspace
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase variable names
Mixing uppercase and lowercase incorrectly
5fill in blank
hard

Fill all three blanks to create a map of environment variables 'BRANCH_NAME', 'JOB_NAME', and 'BUILD_ID' in a Jenkins pipeline Groovy script.

Jenkins
def envMap = [branch: env.[1], job: env.[2], build: env.[3]]
Drag options to blanks, or click blank then click option'
ABRANCH_NAME
BJOB_NAME
CBUILD_ID
DBUILD_NUMBER
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase variable names
Using wrong variable names like BUILD_NUMBER instead of BUILD_ID