how to cd in a jenkins declarative pipeline code example
Example 1: 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"
}
}
}
}
}
}
}
}
Example 2: jenkins declarative pipeline functions
Map modules = [:]
pipeline {
agent any
stages {
stage('test') {
steps {
script{
modules.first = load "first.groovy"
modules.first.test1()
modules.first.test2()
}
}
}
}
}