在Jenkins API中,有没有办法找到上一个版本的git commit?

Nel*_*son 2 git jenkins

我想编写一个脚本来自动为修补程序创建功能分支。为此,我需要弄清楚如何查看当前构建中的最后一次提交。

有没有办法从Jenkins API获取最后的提交?

git checkout -b hotfix <commit>
Run Code Online (Sandbox Code Playgroud)

jil*_*jil 5

您没有指定要使用的API。但是,假设使用Jenkins XML API,它将类似于:

http://myjenkins/job/myJobName/lastBuild/api/xml?xpath=//lastBuiltRevision/SHA1
Run Code Online (Sandbox Code Playgroud)