Loops in Jenkins pipeline
Loops in Jenkins pipeline
Jenkins declarative pipeline for loop
def map = [
Bob : 42,
Alice: 54,
Max : 33
]
pipeline {
agent any
stages {
stage('Initialize') {
steps {
script {
map.each { entry ->
stage (entry.key) {
timestamps{
echo "$entry.value"
}
}
}
}
}
}
}
}
Go to Jenkins dashboard and create a new job click>New item>pipeline
Navigate to the pipeline tab and add the Jenkins loop file
After that click save and go to Jenkins web Ui
on the left side, corner click Build now and our job will run
Finally, we can see the three stages of our Jenkins pipeline scripts created
Relevant Blogs:
Environment variables in pipeline
Recent Comments
No comments
Leave a Comment
We will be happy to hear what you think about this post