ext*_*mkv 5 git continuous-integration jenkins jenkins-pipeline
我想在 PR 中有一个已修改文件的列表,我尝试了一些解决方案,但我只能访问推送到远程的最后一次提交中的修改文件。
例子:
因此,在此示例中,我希望获得 PR 中所有新提交的文件列表。
代码:
def changeLogSets = currentBuild.rawBuild.changeSets
for (int i = 0; i < changeLogSets.size(); i++) {
def entries = changeLogSets[i].items
for (int j = 0; j < entries.length; j++) {
def entry = entries[j]
def files = new ArrayList(entry.affectedFiles)
for (int k = 0; k < files.size(); k++) {
def file = files[k]
print file.path
}
}
}
Run Code Online (Sandbox Code Playgroud)
我使用 git 命令找到了解决方案:
/**
* Compares the current branch and target branch and extract the changed files.
*
* @return the PR changed files.
*/
def getPRChangelog() {
return sh(
script: "git --no-pager diff origin/${params.target} --name-only",
returnStdout: true
).split('\n')
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3018 次 |
| 最近记录: |