0
0
Jenkinsdevops~30 mins

Parameterized builds in Jenkins - Mini Project: Build & Apply

Choose your learning style9 modes available
Parameterized Builds in Jenkins
📖 Scenario: You are a DevOps engineer setting up a Jenkins job that can build different versions of a software project based on user input. This helps your team quickly test or deploy specific versions without changing the job configuration each time.
🎯 Goal: Create a Jenkins pipeline script that accepts a parameter for the software version, uses it in the build steps, and prints the selected version.
📋 What You'll Learn
Create a string parameter called VERSION with default value 1.0
Use the VERSION parameter in a shell build step
Print the selected VERSION value at the end
💡 Why This Matters
🌍 Real World
Parameterized builds let teams run the same Jenkins job with different inputs, saving time and reducing errors.
💼 Career
Knowing how to create and use parameters in Jenkins pipelines is a key skill for DevOps engineers and automation specialists.
Progress0 / 4 steps
1
Define the Jenkins pipeline with a VERSION parameter
Create a Jenkins pipeline script that defines a string parameter called VERSION with the default value 1.0. Use the parameters block to do this.
Jenkins
Need a hint?

Use the parameters block inside the pipeline and add a string parameter with the name VERSION.

2
Add a shell step that uses the VERSION parameter
Inside the Build stage's steps block, add a shell command that echoes Building version: ${VERSION} using the Jenkins parameter VERSION.
Jenkins
Need a hint?

Use the sh step with a command that prints the VERSION parameter value.

3
Add a stage to print the selected VERSION
Add a new stage called Print Version after the Build stage. Inside its steps block, add a shell command that prints Selected version is: ${VERSION}.
Jenkins
Need a hint?

Add a new stage block with the name Print Version and inside it add a sh step to print the version.

4
Run the pipeline and verify the output
Run the Jenkins pipeline script. The output should include the lines Building version: 1.0 and Selected version is: 1.0 when using the default parameter.
Jenkins
Need a hint?

Run the pipeline with default parameters and check the console output for the expected lines.