From 0e700299d7e9d6b433dfd5c98abc6707e88e90f8 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 23 Nov 2023 13:44:49 +0800 Subject: [PATCH] Test deployment to vapor with dynamic commit message from git --- Jenkinsfile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0c6b1422..19ef38d2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -29,9 +29,18 @@ pipeline { stage('get_commit_msg') { steps { + // script { + // commit = sh(returnStdout: true, script: 'git log -1 --oneline').trim() + // env.GIT_COMMIT_MSG = commit + // } script { - commit = sh(returnStdout: true, script: 'git log -1 --oneline').trim() - env.GIT_COMMIT_MSG = commit + def gitExecutable = sh(returnStdout: true, script: 'which git').trim() + if (gitExecutable) { + commit = sh(returnStdout: true, script: "${gitExecutable} log -1 --oneline").trim() + env.GIT_COMMIT_MSG = commit + } else { + echo "Git not found in PATH. Please make sure Git is installed and in the system PATH." + } } } }