Recall & Review
beginner
What is an environment variable in Jenkins builds?
An environment variable is a named value that Jenkins makes available to build steps. It helps pass configuration or secrets without hardcoding them in scripts.
Click to reveal answer
beginner
How can you access environment variables in a Jenkins Pipeline script?
You can access environment variables using the syntax
env.VARIABLE_NAME inside a Pipeline script.Click to reveal answer
intermediate
What is the difference between global and build-specific environment variables in Jenkins?
Global environment variables are set for all builds on the Jenkins server, while build-specific variables are set only for a particular build or job.
Click to reveal answer
beginner
How do you define environment variables in a Jenkins Declarative Pipeline?
Use the
environment block inside the pipeline or stage to define variables, for example:<br>environment {
MY_VAR = 'value'
}Click to reveal answer
beginner
Why should sensitive data be stored as environment variables instead of hardcoded in Jenkins scripts?
Storing sensitive data as environment variables keeps secrets out of code, making it safer and easier to manage access and updates.
Click to reveal answer
How do you reference an environment variable named 'API_KEY' in a Jenkins Pipeline script?
✗ Incorrect
In Jenkins Pipeline scripts, environment variables are accessed using env.VARIABLE_NAME syntax.
Where can you define environment variables that apply to all Jenkins jobs?
✗ Incorrect
Global environment variables are set in Jenkins global configuration and apply to all jobs.
Which Jenkins Pipeline block is used to set environment variables?
✗ Incorrect
The environment block is used to define environment variables in Jenkins Declarative Pipelines.
Why is it better to use environment variables for secrets in Jenkins builds?
✗ Incorrect
Environment variables help keep secrets out of code and logs, improving security.
What happens if you try to access an undefined environment variable in a Jenkins Pipeline?
✗ Incorrect
Accessing an undefined environment variable returns null or empty string without failing the build.
Explain how environment variables are used in Jenkins builds and why they are important.
Think about how you pass information to a recipe without writing it inside the recipe itself.
You got /4 concepts.
Describe how to set and access environment variables in a Jenkins Declarative Pipeline.
Imagine labeling ingredients before cooking and then using those labels during cooking.
You got /4 concepts.