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?
Think about how Jenkins can run scripts to fetch or calculate values just before the build starts.
Dynamic parameters in Jenkins are generated at build time using scripts, often Groovy scripts, which can query external systems or compute values dynamically. This allows parameter options to reflect the current state or environment.
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?
def branches = ['main', 'develop', 'feature-x'] return branches
The script returns a list object directly.
The script defines a list of branch names and returns it. Jenkins expects the script to return a list or array for dynamic parameters.
Which Jenkinsfile snippet correctly defines a dynamic choice parameter that lists files in the workspace directory at build time?
Look for the option that uses a script to dynamically list files at build time.
Option D uses an activeChoiceParam with a Groovy script that runs a shell command to list files and splits the output into a list, which is the correct way to create dynamic choices in Jenkinsfile.
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?
Consider connectivity issues when scripts call external services.
If the script calls an external API and times out, it usually means the Jenkins agent running the script cannot reach the API due to network restrictions or firewall rules.
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?
Think about how one parameter can depend on another's value dynamically.
Option A correctly uses two Active Choices parameters where the second parameter's script dynamically reads the first parameter's selected value to generate relevant branch options, enabling multi-level dynamic selection.