From d570528695e0f7f9f063e84d8f279df02f0c29ce Mon Sep 17 00:00:00 2001
From: wangzilun <964606955@qq.com>
Date: Tue, 08 Mar 2022 17:40:37 +0800
Subject: [PATCH] 补充2
---
Jenkinsfile | 41 +++++++++++++++++++++++------------------
1 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index f184a85..77c74f1 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -20,14 +20,21 @@
stages {
stage('source') {
steps {
- checkout([$class: 'GitSCM'
- , branches: [[name: "${GIT_BRANCH}"]]
- , doGenerateSubmoduleConfigurations: false
- , extensions: []
- , submoduleCfg: []
- , userRemoteConfigs: [[credentialsId: "${GIT_CREDENTIALS_ID}", url: "${url}"]]
- ])
+ script{
+ def changeLogSets = checkout([$class: 'GitSCM'
+ , branches: [[name: "${GIT_BRANCH}"]]
+ , doGenerateSubmoduleConfigurations: false
+ , extensions: []
+ , submoduleCfg: []
+ , userRemoteConfigs: [[credentialsId: "${GIT_CREDENTIALS_ID}", url: "${url}"]]
+ ])
+ println "changeLogSets ${changeLogSets}"
+ GIT_COMMIT = changeLogSets['GIT_COMMIT']
+ GIT_PREVIOUS_COMMIT = changeLogSets['GIT_PREVIOUS_COMMIT']
+ env.GIT_COMMIT_AUTHOR = sh (script: 'git log -1 --oneline --pretty=%an ${GIT_COMMIT}', returnStdout: true).trim()
+ env.GIT_COMMIT_MSG = sh (script: 'git log --pretty=%s ${GIT_PREVIOUS_COMMIT}...${GIT_COMMIT} | awk "\$0=NR\".\"\$0"', returnStdout: true).trim()
+ }
}
}
//stage('testMaven') {
@@ -38,17 +45,6 @@
//}
//}
- stage('testFunction') {
- steps {
- sh '''
- commit_name="\$(git show -s --pretty=%an)"
- commit_message="\$(git show -s --pretty=%s)"
- echo "\$commit_name"
- echo "\$commit_message"
- printenv
- '''
- }
- }
//将项目打成war并归档,将配置文件目录存入stash
stage('package') {
@@ -121,4 +117,13 @@
}
}
}
+
+ post {
+ always {
+ echo "执行完成 \n提交人:${env.GIT_COMMIT_AUTHOR}\n提交信息:\n${env.GIT_COMMIT_MSG}"
+ }
+ unsuccessful{
+ echo 'unsuccessful '
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1