fix(pipeline): update SourceFetcher to use dynamic git credentials ID

Signed-off-by: 孙振宇 <>
This commit is contained in:
孙振宇 2025-02-07 15:57:10 +08:00
parent 044f96d525
commit 9352de5270

View File

@ -15,7 +15,9 @@ import com.freeleaps.devops.enums.CodeLinterTypes
import com.freeleaps.devops.enums.ImageBuilderTypes import com.freeleaps.devops.enums.ImageBuilderTypes
def generateComponentStages(component, configurations) { def generateComponentStages(component, configurations) {
return [ def stages = []
stages.addAll([
// Build Agent Setup
stage("${component.name} :: Build Agent Setup") { stage("${component.name} :: Build Agent Setup") {
script { script {
if (env.executeMode == "fully" || env.changedComponents.contains(component.name)) { if (env.executeMode == "fully" || env.changedComponents.contains(component.name)) {
@ -40,7 +42,7 @@ def generateComponentStages(component, configurations) {
} }
} }
}, },
// Dependencies Resolving
stage("${component.name} :: Dependencies Resolving") { stage("${component.name} :: Dependencies Resolving") {
podTemplate( podTemplate(
label: "dep-resolver-${component.name}", label: "dep-resolver-${component.name}",
@ -81,7 +83,11 @@ 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 { script {
if (env.executeMode == "fully" || env.changedComponents.contains(component.name)) { if (env.executeMode == "fully" || env.changedComponents.contains(component.name)) {
@ -110,13 +116,8 @@ def generateComponentStages(component, configurations) {
} }
} }
}, },
// Code Linting
stage("${component.name} :: Code Linting If Enabled") { stage("${component.name} :: Code Linting") {
when {
expression {
return (env.executeMode == "fully" || env.changedComponents.contains(component.name)) && env.linterContainerImage != null && !env.linterContainerImage.isEmpty()
}
}
podTemplate( podTemplate(
label: "code-linter-${component.name}", label: "code-linter-${component.name}",
containers: [ containers: [
@ -149,8 +150,13 @@ 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 { script {
if (env.executeMode == "fully" || env.changedComponents.contains(component.name)) { if (env.executeMode == "fully" || env.changedComponents.contains(component.name)) {
@ -174,8 +180,8 @@ def generateComponentStages(component, configurations) {
} }
} }
}, },
// SAST Scanning
stage("${component.name} :: SAST Scanning If Enabled") { stage("${component.name} :: SAST Scanning") {
when { when {
expression { expression {
return (env.executeMode == "fully" || env.changedComponents.contains(component.name)) && env.sastScannerContainerImage != null && !env.sastScannerContainerImage.isEmpty() return (env.executeMode == "fully" || env.changedComponents.contains(component.name)) && env.sastScannerContainerImage != null && !env.sastScannerContainerImage.isEmpty()
@ -213,8 +219,13 @@ def generateComponentStages(component, configurations) {
} }
} }
} }
}, }
])
}
if (component.semanticReleaseEnabled != null && component.semanticReleaseEnabled) {
stages.addAll([
// Semantic Release Environment Preparation
stage("${component.name} :: Semantic Release Preparation") { stage("${component.name} :: Semantic Release Preparation") {
script { script {
if (env.executeMode == "fully" || env.changedComponents.contains(component.name)) { if (env.executeMode == "fully" || env.changedComponents.contains(component.name)) {
@ -231,8 +242,8 @@ def generateComponentStages(component, configurations) {
} }
} }
}, },
// Semantic Releasing
stage("${component.name} :: Semantic Releasing If Enabled") { stage("${component.name} :: Semantic Releasing") {
when { when {
expression { expression {
return (env.executeMode == "fully" || env.changedComponents.contains(component.name)) && env.semanticReleasingContainerImage != null && !env.semanticReleasingContainerImage.isEmpty() return (env.executeMode == "fully" || env.changedComponents.contains(component.name)) && env.semanticReleasingContainerImage != null && !env.semanticReleasingContainerImage.isEmpty()
@ -268,8 +279,12 @@ def generateComponentStages(component, configurations) {
} }
} }
} }
}, }
])
}
stages.addAll([
// Compilation & Packaging
stage("${component.name} :: Compilation & Packaging") { stage("${component.name} :: Compilation & Packaging") {
podTemplate( podTemplate(
label: "build-agent-${component.name}", label: "build-agent-${component.name}",
@ -319,7 +334,7 @@ def generateComponentStages(component, configurations) {
} }
} }
}, },
// Image Builder Setup
stage("${component.name} :: Image Builder Setup") { stage("${component.name} :: Image Builder Setup") {
script { script {
if (env.executeMode == "fully" || env.changedComponents.contains(component.name)) { if (env.executeMode == "fully" || env.changedComponents.contains(component.name)) {
@ -340,7 +355,7 @@ def generateComponentStages(component, configurations) {
} }
} }
}, },
// Image Building & Publishing
stage("${component.name} :: Image Building & Publishing") { stage("${component.name} :: Image Building & Publishing") {
when { when {
expression { expression {
@ -400,11 +415,8 @@ def generateComponentStages(component, configurations) {
} }
} }
} }
])
// stage("${component.name} :: Argo Application Version Updating (Deploying)") { return stages
// }
]
} }
def call(Closure closure) { def call(Closure closure) {