From e33ac09e2affa4d53b4344d5d83af3d75a3e719c 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 11:15:00 +0800 Subject: [PATCH] refactor(CommitMessageLinter): ensure workspace is a trusted git repository for commit linting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙振宇 <> --- .../src/com/freeleaps/devops/CommitMessageLinter.groovy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/first-class-pipeline/src/com/freeleaps/devops/CommitMessageLinter.groovy b/first-class-pipeline/src/com/freeleaps/devops/CommitMessageLinter.groovy index 3c632cad..21176eb7 100644 --- a/first-class-pipeline/src/com/freeleaps/devops/CommitMessageLinter.groovy +++ b/first-class-pipeline/src/com/freeleaps/devops/CommitMessageLinter.groovy @@ -26,6 +26,8 @@ class CommitMessageLinter { steps.log.info " Linting commit messages from HEAD..." steps.dir(steps.env.workspace) { + // commit lint cli requires a git repository to lint commit messages, so we need make sure the workspace is a trusted git repository + steps.sh "git config --global --add safe.directory ${steps.env.workspace}" steps.sh "commitlint --verbose -g ${rules} -f HEAD^" } }