Part 10: Environment Variables in Pipelines
Make it variables and reusable

Search for a command to run...
Make it variables and reusable

No comments yet. Be the first to comment.
Azure Solution for SmartBuildings

RAG

Scaling pipeline to accept Dynamic inputs

Scaling with branches

Understand how to use environment variables in Jenkins pipelines
Define variables at:
Global level
Pipeline level
Stage level
Use environment variables to control pipeline behavior dynamically
Learn how to manage sensitive data securely
The purpose of this part is to make your pipelines configurable, reusable, and secure.
So far, you have:
Static pipelines
Parameterized inputs
But real-world pipelines require:
Managing configuration like URLs, ports, and credentials
Handling different environments (Dev, UAT, Prod)
Avoiding hardcoding sensitive data in scripts
Environment variables help you:
Centralize configuration
Reuse pipelines across environments
Improve maintainability and readability
This is a core DevOps practice used in:
CI/CD pipelines
Kubernetes deployments
Cloud-native applications
Before starting this part, ensure:
Host and the directory structure to run Dockerfiles and docker-compose.yml (Refer to Part 1)pipeline {
agent any
environment {
def myString = "Hello World"
def myNumber = 10
def myBool = true
}
stages{
stage("Demo") {
steps {
echo "myString: ${myString}"
echo "myNumber: ${myNumber}"
echo "myBool: ${myBool}"
}
}
}
}
pipeline script
Build Now
Now we can see the pipeline using the variables given in the environment block
In this part, you upgraded your pipeline to a fully configurable and production-ready CI/CD system
You learned how to:
Use environment variables effectively in pipelines
Avoid hardcoding values
Manage configurations across environments
Improve pipeline reusability and security
This is how modern DevOps pipelines are designed:
Flexible across environments
Secure with proper secret handling
Easy to maintain and scale
π Congratulations! we have completed the Jenkins CI/CD Mastery Series
We have built:
End-to-end CI/CD pipelines
Scalable automation workflows
Production-ready DevOps practices
β¬
οΈ Previous Article: Part 9 Parameterized Pipelines
β‘οΈ Next Article: Home
β If you found this article useful, follow https://ask-abhi.com for more DevOps tutorials.