From ef9c74a43e01af1a14f8d4174435854b14b4c80a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=8C=AF=E5=AE=87?= <> Date: Mon, 10 Feb 2025 07:03:47 +0800 Subject: [PATCH] fix(pipeline): correct stage closure syntax in component stage generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙振宇 <> --- .../vars/executeFreeleapsPipeline.groovy | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/first-class-pipeline/vars/executeFreeleapsPipeline.groovy b/first-class-pipeline/vars/executeFreeleapsPipeline.groovy index 7eeb5bcc..365388b8 100644 --- a/first-class-pipeline/vars/executeFreeleapsPipeline.groovy +++ b/first-class-pipeline/vars/executeFreeleapsPipeline.groovy @@ -18,7 +18,7 @@ def generateComponentStages(component, configurations) { def stages = [] stages.addAll([ // Build Agent Setup - stage("${component.name} :: Build Agent Setup") { + {stage("${component.name} :: Build Agent Setup") { script { if (env.executeMode == "fully" || env.changedComponents.contains(component.name)) { def buildAgentImage = component.buildAgentImage @@ -41,9 +41,9 @@ def generateComponentStages(component, configurations) { env.buildAgentImage = buildAgentImage } } - }, + }}, // Dependencies Resolving - stage("${component.name} :: Dependencies Resolving") { + {stage("${component.name} :: Dependencies Resolving") { podTemplate( label: "dep-resolver-${component.name}", containers: [ @@ -82,13 +82,13 @@ def generateComponentStages(component, configurations) { } } } - }, + }}, ]) if (component.lintEnabled != null && component.lintEnabled) { stages.addAll([ // Code Linter Environment Preparation - stage("${component.name} :: Code Linter Preparation") { + {stage("${component.name} :: Code Linter Preparation") { script { if (env.executeMode == "fully" || env.changedComponents.contains(component.name)) { if (component.lintEnabled != null && component.lintEnabled) { @@ -115,9 +115,9 @@ def generateComponentStages(component, configurations) { } } } - }, + }}, // Code Linting - stage("${component.name} :: Code Linting") { + {stage("${component.name} :: Code Linting") { podTemplate( label: "code-linter-${component.name}", containers: [ @@ -166,14 +166,14 @@ def generateComponentStages(component, configurations) { } } } - } + }} ]) } if (component.sastEnabled != null && component.sastEnabled) { stages.addAll([ // SAST Scanner Environment Preparation - stage("${component.name} :: SAST Scanner Preparation") { + {stage("${component.name} :: SAST Scanner Preparation") { script { if (env.executeMode == "fully" || env.changedComponents.contains(component.name)) { if (component.sastEnabled != null && component.sastEnabled) { @@ -195,9 +195,9 @@ def generateComponentStages(component, configurations) { } } } - }, + }}, // SAST Scanning - stage("${component.name} :: SAST Scanning") { + {stage("${component.name} :: SAST Scanning") { when { expression { return (env.executeMode == "fully" || env.changedComponents.contains(component.name)) && env.sastScannerContainerImage != null && !env.sastScannerContainerImage.isEmpty() @@ -235,14 +235,14 @@ def generateComponentStages(component, configurations) { } } } - } + }} ]) } if (component.semanticReleaseEnabled != null && component.semanticReleaseEnabled) { stages.addAll([ // Semantic Releasing - stage("${component.name} :: Semantic Releasing") { + {stage("${component.name} :: Semantic Releasing") { podTemplate( label: "semantic-releasing-${component.name}", containers: [ @@ -273,13 +273,13 @@ def generateComponentStages(component, configurations) { } } } - } + }} ]) } stages.addAll([ // Compilation & Packaging - stage("${component.name} :: Compilation & Packaging") { + {stage("${component.name} :: Compilation & Packaging") { podTemplate( label: "build-agent-${component.name}", containers: [ @@ -349,9 +349,9 @@ def generateComponentStages(component, configurations) { } } } - }, + }}, // Image Builder Setup - stage("${component.name} :: Image Builder Setup") { + {stage("${component.name} :: Image Builder Setup") { script { if (env.executeMode == "fully" || env.changedComponents.contains(component.name)) { log.info("Pipeline", "Ready to setup image builder for ${component.name}") @@ -370,9 +370,9 @@ def generateComponentStages(component, configurations) { log.info("Pipeline", "Using ${imageBuilder.builder} (image: ${imageBuilder.image}) as image builder for ${component.name}") } } - }, + }}, // Image Building & Publishing - stage("${component.name} :: Image Building & Publishing") { + {stage("${component.name} :: Image Building & Publishing") { podTemplate( label: "image-builder-${component.name}", containers: [ @@ -441,11 +441,11 @@ def generateComponentStages(component, configurations) { } } } - } + }} ]) return { - stages.each { stage -> - stage.call() + stages.each { stageClosure -> + stageClosure() } } } @@ -555,7 +555,7 @@ spec: steps { script { def componentStages = configurations.components.collectEntries { component -> - ["Generated Stage :: ${component}": generateComponentStages(component, configurations)] + ["Generated Stage :: ${component.name}": generateComponentStages(component, configurations)] } parallel componentStages }