我有一个GitChangeSet
对象(最终来自构建)。我想找到与该提交关联的存储库名称或 URL。但是,该对象的任何属性似乎都没有暗示此提交最终来自何处。例如:
affectedFiles=[hudson.plugins.git.GitChangeSet$Path@2a7ac0cb, hudson.plugins.git.GitChangeSet$Path@1d9fb12a, hudson.plugins.git.GitChangeSet$Path@3b47e461, hudson.plugins.git.GitChangeSet$Path@35be1e86]
comment=CF-703 - remove testing-only hostsfile entry that caused "hostname -f"
to return "localhost"
date=2017-12-19 16:25:17 -0700
id=cfc01dfbf1015496074c2c1e6c9663cfb0f49751
commitId=cfc01dfbf1015496074c2c1e6c9663cfb0f49751
branch=null
msgEscaped=CF-703 - remove testing-only hostsfile entry that caused "hostname -f"
timestamp=1513725917000
authorName=hendrenj
parentCommit=bf4b919e74c635c61c4761134d6b53445829593d
msg=CF-703 - remove testing-only hostsfile entry that caused "hostname -f"
class=class hudson.plugins.git.GitChangeSet
msgAnnotated=CF-703 - remove testing-only hostsfile entry that caused "hostname -f"
commentAnnotated=CF-703 - remove testing-only hostsfile entry that caused "hostname -f"<br>to return "localhost"<br>
revision=cfc01dfbf1015496074c2c1e6c9663cfb0f49751
paths=[hudson.plugins.git.GitChangeSet$Path@2a7ac0cb, hudson.plugins.git.GitChangeSet$Path@1d9fb12a, hudson.plugins.git.GitChangeSet$Path@3b47e461, hudson.plugins.git.GitChangeSet$Path@35be1e86]
createAccountBasedOnEmail=false
affectedPaths=[recipes/default_vhost.rb, metadata.rb, test/integration/shared/serverspec/default_vhost/default_vhost.rb, Policyfile.lock.json]
authorEmail=*******@*******.***
parent=hudson.plugins.git.GitChangeSetList@2eb9acad
author=Jay Hendren
我通过迭代得到了这个提交对象build.changeSets
(我相信它来自类hudson.model.AbstractBuild
)。我确实知道这个特定的提交来自一个全局共享库存储库,而不是与这个构建关联的主存储库,但我没有看到任何明显的方式来以编程方式提取该信息。 如何以编程方式确定GitChangeSet
对象(或一般其他对象hudson.model.AbstractBuild.changeSets
)来自哪个存储库?
作为上下文,我正在为失败的构建开发一个电子邮件报告,其中收集与失败的构建相关的提交列表。由于我的作业之间存在复杂的上游/下游关系,一个存储库中的提交可能会触发一系列构建,因为成功的构建会触发依赖上游作业的下游作业。此外,还有其他与我的构建相关的存储库,特别是全局共享库存储库。我希望我的报告提及最终导致当前版本的一系列构建的提交。到目前为止,找到这些上游提交并没有太痛苦(感谢UpstreamJobCause
),但我已经挂断了确定这些提交最终来自哪里。如果您不知道我的问题的答案,我将不胜感激评论中有关此问题的替代方法的任何建议。