Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase variable names like $home
Using incorrect syntax like env.HOME without proper context
✗ Incorrect
In Jenkins pipeline scripts, environment variables can be accessed using the $ sign followed by the variable name in uppercase, like $HOME.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase variable names
Trying to access variables as env.BUILD_NUMBER without proper syntax
✗ Incorrect
Jenkins environment variables are uppercase and accessed with $ followed by the variable name, so $BUILD_NUMBER is correct.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'env.PATH' which is not valid in shell steps
Using lowercase 'path' which is not recognized
✗ Incorrect
In Jenkins pipeline shell steps, environment variables are accessed with $ followed by the variable name in uppercase without 'env.' prefix.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase variable names
Mixing uppercase and lowercase incorrectly
✗ Incorrect
Environment variables in Jenkins are uppercase and accessed with $ followed by the variable name, so $USER and $WORKSPACE are correct.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase variable names
Using wrong variable names like BUILD_NUMBER instead of BUILD_ID
✗ Incorrect
In Jenkins pipeline Groovy scripts, environment variables are accessed via 'env.VARIABLE_NAME' with uppercase names like BRANCH_NAME, JOB_NAME, and BUILD_ID.