From bc29cf35146d105b915a05f78062189f193cd5d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=8C=AF=E5=AE=87?= <> Date: Tue, 4 Feb 2025 12:11:42 +0800 Subject: [PATCH] refactor(executeFreeleapsPipeline): streamline commit message linting logic and improve conditional checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙振宇 <> --- .../vars/executeFreeleapsPipeline.groovy | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/first-class-pipeline/vars/executeFreeleapsPipeline.groovy b/first-class-pipeline/vars/executeFreeleapsPipeline.groovy index 13543cb2..844f3e76 100644 --- a/first-class-pipeline/vars/executeFreeleapsPipeline.groovy +++ b/first-class-pipeline/vars/executeFreeleapsPipeline.groovy @@ -25,6 +25,11 @@ def call(Closure closure) { stages { stage("Commit Linting If Enabled") { + when { + expression { + return configurations.commitMessageLintEnabled != null && configurations.commitMessageLintEnabled + } + } agent { kubernetes { defaultContainer 'commit-message-linter' @@ -52,17 +57,11 @@ spec: } steps { script { - def enabled = configurations.commitMessageLintEnabled - - if (enabled == null || !enabled) { - log.warn("Pipeline","Commit message linting is disabled") - } else if (enabled) { - log.info("Pipeline","Commit message linting is enabled") - sourceFetcher.fetch(configurations) + log.info("Pipeline","Commit message linting is enabled") + sourceFetcher.fetch(configurations) - def linter = new CommitMessageLinter(this) - linter.lint(configurations) - } + def linter = new CommitMessageLinter(this) + linter.lint(configurations) } } } @@ -74,7 +73,7 @@ spec: if (executeMode == null || executeMode.isEmpty()) { log.warn("Pipeline","Not set executeMode, using fully as default execute mode") env.executeMode = "fully" - } else if (executeMode == 'on-demand' && serviceGitRepoType != 'monorepo') { + } else if (executeMode == 'on-demand' && configurations.serviceGitRepoType != 'monorepo') { log.warn("Pipeline","serviceGirRepoType is not monorepo, on-demand mode is not supported, using fully mode") env.executeMode = "fully" } else {