0
0
Jenkinsdevops~20 mins

Dynamic parameter values in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Dynamic Parameter Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Dynamic Parameter Values in Jenkins

In Jenkins, dynamic parameters allow parameter values to be generated at build time. Which of the following best describes how dynamic parameter values are typically generated?

ABy manually entering parameter values each time the build runs
BBy hardcoding all parameter values in the Jenkinsfile before the build starts
CBy using a Groovy script or external script to generate parameter values when the build is triggered
DBy setting static environment variables in the Jenkins global configuration
Attempts:
2 left
💡 Hint

Think about how Jenkins can run scripts to fetch or calculate values just before the build starts.

💻 Command Output
intermediate
1:30remaining
Output of a Groovy Script for Dynamic Parameters

Given the following Groovy script used in a Jenkins Active Choices parameter to generate a list of branches from a Git repository, what is the expected output?

Jenkins
def branches = ['main', 'develop', 'feature-x']
return branches
A['main', 'develop', 'feature-x']
Bmain, develop, feature-x
CError: Missing return statement
Dnull
Attempts:
2 left
💡 Hint

The script returns a list object directly.

Configuration
advanced
2:00remaining
Configuring a Dynamic Choice Parameter in Jenkinsfile

Which Jenkinsfile snippet correctly defines a dynamic choice parameter that lists files in the workspace directory at build time?

Aproperties([parameters([choice(name: 'FILES', choices: sh(script: 'ls', returnStdout: true), description: 'Select a file')])])
Bproperties([parameters([activeChoiceParam(name: 'FILES') { script { return ['file1', 'file2'] } }])])
Cproperties([parameters([choice(name: 'FILES', choices: ['file1', 'file2'], description: 'Select a file')])])
Dproperties([parameters([activeChoiceParam(name: 'FILES') { script { return sh(script: 'ls', returnStdout: true).split('\n') } }])])
Attempts:
2 left
💡 Hint

Look for the option that uses a script to dynamically list files at build time.

Troubleshoot
advanced
1:30remaining
Troubleshooting Dynamic Parameter Script Failure

A Jenkins Active Choices parameter script that queries an external API to generate options suddenly fails with a timeout error. What is the most likely cause?

AThe script syntax is invalid and causes a compilation error
BThe Jenkins agent does not have network access to the external API
CThe parameter name is missing in the Jenkinsfile
DThe Jenkins master is offline
Attempts:
2 left
💡 Hint

Consider connectivity issues when scripts call external services.

🔀 Workflow
expert
2:30remaining
Implementing a Multi-Level Dynamic Parameter Workflow

You want to create a Jenkins job with two dynamic parameters: the first lists available projects, and the second lists branches for the selected project. Which workflow correctly implements this multi-level dynamic parameter setup?

AUse two Active Choices parameters where the second parameter's script reads the first parameter's value and queries branches accordingly
BUse two static choice parameters with hardcoded project and branch lists
CUse a single parameter that combines project and branch names in one list
DUse environment variables to pass project and branch names between builds
Attempts:
2 left
💡 Hint

Think about how one parameter can depend on another's value dynamically.