Skip to content

Instantly share code, notes, and snippets.

@slide
Created October 20, 2020 16:54
Show Gist options
  • Save slide/10db86a68f68e53278ce7e157564b920 to your computer and use it in GitHub Desktop.
Save slide/10db86a68f68e53278ce7e157564b920 to your computer and use it in GitHub Desktop.
def buildmap = [:]
pipeline {
agent {
label 'build'
}
environment {
//Sets the codedir that have been changed under services sub-directories
CODEDIR = '1 2 3'
} //end environment
stages {
stage ('Steps') {
steps {
script {
echo "CODEDIR = ${env.CODEDIR}"
codedirarray = env.CODEDIR.split(" ")
for (int i = 0; i < codedirarray.size(); i++) {
def codevar = codedirarray[i]
buildmap[codevar] = {
stage("Build and Unit Tests: " + codevar) {
script {
echo "variable codevar ${codevar}"
} //end script
echo "codevar " + codevar
echo "variable codevar ${codevar}"
}//end build and unit test stage
stage("Functional Tests: " + codevar) {
script {
echo "variable codevar ${codevar}"
} //end script
}//end functional tests
}//end buildmap
}//end codearray for itterarion
}//end script
}// end steps
} // End stage
stage ('parallel test') {
steps {
script {
parallel(buildmap)
}
}
}
}//end stages
post {
always {
cleanWs()
}
} // end post
} // end pipeline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment