Resolve several issues with dynamic stages.
This commit is contained in:
parent
1f0749b24c
commit
a261f8fec5
|
@ -40,6 +40,28 @@ echo "Use settings file at ${maven_settings_file}"
|
|||
echo "Use local repo at ${maven_local_repo_path}"
|
||||
echo "Release number: ${params.gCube_release_number}"
|
||||
|
||||
def apps = ['SmartGears':['maven-parent', 'gcube-bom', 'gxRest'],
|
||||
'Enabling':['job4', 'job5', 'job6'],
|
||||
'Data':['job7', 'job8', 'job9']]
|
||||
def dynamicStages = [:]
|
||||
|
||||
//let's build the stages closures
|
||||
apps.each { entry -> echo "App name: $entry.key = Jobs: $entry.value" }
|
||||
apps.each { entry ->
|
||||
def app = entry.key
|
||||
dynamicStages["stage-${app}"] = ["${app}":{
|
||||
node {
|
||||
stage("Build ${app}") {
|
||||
for (int j = 0; j < entry.value.size(); j++) {
|
||||
build "${entry.value[j]}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
echo "Configured dynamic stages: ${dynamicStages.inspect()}"
|
||||
|
||||
pipeline {
|
||||
// see https://jenkins.io/doc/book/pipeline/syntax/#agent
|
||||
agent {
|
||||
|
@ -78,36 +100,31 @@ pipeline {
|
|||
|
||||
}
|
||||
}
|
||||
stage('build core components') {
|
||||
stage('Build Components') {
|
||||
stages {
|
||||
stage('Build SmartGears components') {
|
||||
steps {
|
||||
withMaven(jdk: "${maven_jdk}", mavenLocalRepo: "${maven_local_repo_path}", mavenSettingsFilePath: "${maven_settings_file}") {
|
||||
build 'maven-parent'
|
||||
build 'gcube-bom'
|
||||
build 'authorization-common-library'
|
||||
build 'gxRest'
|
||||
script {
|
||||
parallel dynamicStages['stage-SmartGears']
|
||||
}
|
||||
echo "Done with core components"
|
||||
}
|
||||
}
|
||||
stage('Build enabling components') {
|
||||
steps {
|
||||
script {
|
||||
parallel dynamicStages['stage-Enabling']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// post-build actions
|
||||
post {
|
||||
always {
|
||||
echo 'This will always run'
|
||||
stage('Build data components') {
|
||||
steps {
|
||||
script {
|
||||
parallel dynamicStages['stage-Data']
|
||||
}
|
||||
success {
|
||||
echo 'This will run only if successful'
|
||||
}
|
||||
failure {
|
||||
echo 'This will run only if failed'
|
||||
}
|
||||
unstable {
|
||||
echo 'This will run only if the run was marked as unstable'
|
||||
}
|
||||
changed {
|
||||
echo 'This will run only if the state of the Pipeline has changed'
|
||||
echo 'For example, if the Pipeline was previously failing but is now successful'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,25 +40,6 @@ echo "Use settings file at ${maven_settings_file}"
|
|||
echo "Use local repo at ${maven_local_repo_path}"
|
||||
echo "Release number: ${params.gCube_release_number}"
|
||||
|
||||
def apps = ['stage1':['job1', 'job2', 'job3'],
|
||||
'stage2':['job4', 'job5', 'job6'],
|
||||
'stage3':['job7', 'job8', 'job9']]
|
||||
def dynamicStages = [:]
|
||||
|
||||
//let's build the stages closures
|
||||
for (int i = 0; i < apps.size(); i++) {
|
||||
def app = apps[i]
|
||||
dynamicStages["stage-${app}"] = ["${app}":{
|
||||
node {
|
||||
stage("Build ${app}") {
|
||||
for (int j = 0; j < app.size(); j++) {
|
||||
build "${app[j]}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
pipeline {
|
||||
// see https://jenkins.io/doc/book/pipeline/syntax/#agent
|
||||
agent {
|
||||
|
@ -97,31 +78,36 @@ pipeline {
|
|||
|
||||
}
|
||||
}
|
||||
stage('Build Components') {
|
||||
stages {
|
||||
stage('Build SmartGears components') {
|
||||
stage('build core components') {
|
||||
steps {
|
||||
script {
|
||||
parallel dynamicStages['stage-SmartGears']
|
||||
withMaven(jdk: "${maven_jdk}", mavenLocalRepo: "${maven_local_repo_path}", mavenSettingsFilePath: "${maven_settings_file}") {
|
||||
build 'maven-parent'
|
||||
build 'gcube-bom'
|
||||
build 'authorization-common-library'
|
||||
build 'gxRest'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build enabling components') {
|
||||
steps {
|
||||
script {
|
||||
parallel dynamicStages['stage-Enabling']
|
||||
echo "Done with core components"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build data components') {
|
||||
steps {
|
||||
script {
|
||||
parallel dynamicStages['stage-Data']
|
||||
// post-build actions
|
||||
post {
|
||||
always {
|
||||
echo 'This will always run'
|
||||
}
|
||||
success {
|
||||
echo 'This will run only if successful'
|
||||
}
|
||||
failure {
|
||||
echo 'This will run only if failed'
|
||||
}
|
||||
unstable {
|
||||
echo 'This will run only if the run was marked as unstable'
|
||||
}
|
||||
changed {
|
||||
echo 'This will run only if the state of the Pipeline has changed'
|
||||
echo 'For example, if the Pipeline was previously failing but is now successful'
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue