3

私は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 &quot;hostname -f&quot;<br>to return &quot;localhost&quot;<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

私はこの commit オブジェクトを繰り返し処理して取得しましたbuild.changeSets(これは class から来ていると思いますhudson.model.AbstractBuild)。この特定のコミットが、このビルドに関連付けられたメイン リポジトリではなく、グローバルな共有ライブラリ リポジトリからのものであることは知っていますが、その情報をプログラムで抽出する明らかな方法は見当たりません。 オブジェクト (または一般的に他のオブジェクト) がどのリポジトリから来たかをプログラムで特定するにはどうすればよいですか?GitChangeSethudson.model.AbstractBuild.changeSets


参考までに、失敗したビルドに関する電子メール レポートを作成しています。このレポートでは、特に、失敗したビルドに関連するコミットのリストを収集しています。ジョブ間に複雑なアップストリーム/ダウンストリームの関係があるため、ビルドが成功するとアップストリームのジョブに依存するダウンストリーム ジョブがトリガーされるため、1 つのリポジトリでコミットすると一連のビルドがトリガーされる場合があります。さらに、ビルドに関連付けられた他のリポジトリ、特にグローバルな共有ライブラリ リポジトリがあります。現在のビルドに至る一連のビルドの最終的な責任を負うのはどのコミットかについて、レポートで言及したいと思います。これらの上流のコミットを見つけることは、今のところそれほど苦痛ではありません (おかげでUpstreamJobCause)、しかし、私はそれらのコミットが最終的にどこから来たのかを判断することに夢中になりました。述べたように私の質問に対する答えがわからない場合は、コメントでこの問題に対する代替アプローチに関する提案をいただければ幸いです。

4

3 に答える 3