简化子分支显示流程, 显示最新子分支的提交信息
This commit is contained in:
parent
f61370a82d
commit
25d1568d74
@ -3,8 +3,6 @@
|
||||
// Copyright Byway Studios Inc. All rights reserved
|
||||
//=================================================================
|
||||
|
||||
import groovy.json.JsonOutput
|
||||
import groovy.json.JsonSlurperClassic
|
||||
import com.cloudbees.groovy.cps.NonCPS
|
||||
|
||||
@NonCPS
|
||||
@ -154,19 +152,8 @@ def call(Map config)
|
||||
// 收集提交记录
|
||||
def changeString = getMainRepoChangeString(currentBuild.changeSets)
|
||||
|
||||
// 收集子模块提交记录(与上一次构建对比)
|
||||
// 收集子模块当前提交记录
|
||||
def submoduleChangeString = ""
|
||||
def submoduleStateFile = ".jenkins_submodule_state_dev.json"
|
||||
def previousSubmoduleStates = [:]
|
||||
def currentSubmoduleStates = [:]
|
||||
|
||||
if (fileExists(submoduleStateFile)) {
|
||||
try {
|
||||
previousSubmoduleStates = new JsonSlurperClassic().parseText(readFile(submoduleStateFile)) ?: [:]
|
||||
} catch (Exception ignored) {
|
||||
previousSubmoduleStates = [:]
|
||||
}
|
||||
}
|
||||
|
||||
if (fileExists('.git') && fileExists('.gitmodules')) {
|
||||
try {
|
||||
@ -206,27 +193,8 @@ def call(Map config)
|
||||
script: "@echo off\r\ngit -C \"${submodulePath}\" log -1 --pretty=format:\"%%h %%s - %%an\""
|
||||
).trim()
|
||||
|
||||
currentSubmoduleStates[submodulePath] = [sha: currentSha]
|
||||
|
||||
def previousSha = previousSubmoduleStates[submodulePath]?.sha
|
||||
if (previousSha && previousSha != currentSha) {
|
||||
def commitLogs = ""
|
||||
try {
|
||||
commitLogs = bat(
|
||||
returnStdout: true,
|
||||
script: "@echo off\r\ngit -C \"${submodulePath}\" log --pretty=format:\"- %%h %%s - %%an\" ${previousSha}..${currentSha}"
|
||||
).trim()
|
||||
} catch (Exception ignored) {
|
||||
commitLogs = "- ${currentHeadMessage}"
|
||||
}
|
||||
|
||||
if (!commitLogs) {
|
||||
commitLogs = "- ${currentHeadMessage}"
|
||||
}
|
||||
|
||||
submoduleSections << "- 子模块: ${submodulePath}\n${commitLogs}"
|
||||
} else if (!previousSha) {
|
||||
submoduleSections << "- 子模块: ${submodulePath}\n- 首次记录: ${currentHeadMessage}"
|
||||
if (currentSha) {
|
||||
submoduleSections << "- 子模块: ${submodulePath}\n- 当前提交: ${currentHeadMessage}"
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,11 +203,6 @@ def call(Map config)
|
||||
} else {
|
||||
submoduleChangeString = "\n\n子模块提交记录: 无变更"
|
||||
}
|
||||
|
||||
writeFile(
|
||||
file: submoduleStateFile,
|
||||
text: JsonOutput.prettyPrint(JsonOutput.toJson(currentSubmoduleStates))
|
||||
)
|
||||
} catch (Exception ex) {
|
||||
echo "子模块提交记录收集失败: ${ex.message}"
|
||||
submoduleChangeString = "\n\n子模块提交记录: 收集失败"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user