Recall & Review
beginner
What does 'avoiding hard-coded values' mean in Jenkins pipelines?
It means not writing fixed values directly in the pipeline script. Instead, use variables or parameters so you can change values without editing the code.
Click to reveal answer
beginner
Why should you avoid hard-coded values in Jenkins pipelines?
Because hard-coded values make scripts less flexible and harder to maintain. Using variables or parameters helps reuse the pipeline for different projects or environments easily.
Click to reveal answer
intermediate
How can you pass values to a Jenkins pipeline without hard-coding?
You can use parameters in the pipeline, environment variables, or external configuration files to pass values dynamically.
Click to reveal answer
beginner
Example: How to define a string parameter in a Jenkins declarative pipeline?
Use the parameters block like this:<br>
parameters {
string(name: 'BRANCH_NAME', defaultValue: 'main', description: 'Git branch to build')
}Click to reveal answer
intermediate
What is the benefit of using environment variables in Jenkins pipelines?
Environment variables let you store values outside the code and reuse them in multiple places. This avoids repeating hard-coded values and makes updates easier.Click to reveal answer
Which method helps avoid hard-coded values in Jenkins pipelines?
✗ Incorrect
Using parameters and environment variables allows dynamic input and avoids fixed values in the pipeline.
How do you define a string parameter in a Jenkins declarative pipeline?
✗ Incorrect
The parameters block with string() defines a string parameter for the pipeline.
What is a risk of hard-coding values in Jenkins pipelines?
✗ Incorrect
Hard-coded values reduce flexibility and make maintenance difficult.
Which of these is NOT a way to avoid hard-coded values?
✗ Incorrect
Writing fixed values directly is exactly what we want to avoid.
What does the 'environment' block in Jenkins pipeline do?
✗ Incorrect
The environment block sets environment variables accessible during the pipeline run.
Explain why avoiding hard-coded values is important in Jenkins pipelines and how you can implement it.
Think about how changing values without editing code helps.
You got /4 concepts.
Describe how to define and use a string parameter in a Jenkins declarative pipeline.
Look for the parameters { string(...) } syntax.
You got /3 concepts.