VCS ルートを管理する
この記事では、VCS ルートに関する RESTAPI リクエストを一覧表示します。
VCS ルートを一覧表示する
すべての VCS ルートを取得するには、次を使用します。
/app/rest/vcs-roots
エンドポイントは、VcsRoot のインスタンスを含む VcsRoots エンティティで応答します。
特定のルートを取得するには、次を使用します。
/app/rest/vcs-roots/<vcsRootLocator>
vcsRootLocator は、VcsRootLocator エンティティとして入力されます。例: ID MyCustomRoot の VCS ルートを取得するには、次を使用します。
/app/rest/vcs-roots/id:MyCustomRoot
すべての Git ベースの VCS ルートを取得するには、次を使用します。
/app/rest/vcs-roots/type:jetbrains.git
VCS ルートを作成する
新しい VCS ルートを作成するには、VcsRoot エンティティを次の宛先に POST します。
/app/rest/vcs-roots
ペイロードの例:
<vcs-root id="MyCustomRoot" name="MyCustomRoot" vcsName="jetbrains.git">
<project id="MyCustomProject"/>
<properties count="3">
<property name="authMethod" value="ANONYMOUS"/>
<property name="branch" value="refs/heads/master"/>
<property name="url" value="https://mygitserver.com/myrepo"/>
</properties>
</vcs-root>
{
"id": "MyCustomRoot",
"name": "MyCustomRoot",
"vcsName": "jetbrains.git",
"project": {
"id": "MyCustomProject"
},
"properties": {
"property": [
{
"name": "authMethod",
"value": "ANONYMOUS"
},
{
"name": "branch",
"value": "refs/heads/master"
},
{
"name": "url",
"value": "https://mygitserver.com/myrepo"
}
]
}
}
VCS ルートを削除する
VCS ルートを削除するには、次を使用します。
/app/rest/vcs-roots/<vcsRootLocator>
VCS ルート定義を更新する
特定の VCS ルートプロパティは、次の方法で取得できます。
/app/rest/vcs-roots/<vcsRootLocator>/properties/<property_name>
text/plain 本体を使用して PUT リクエストで更新します。
/app/rest/vcs-roots/<vcsRootLocator>/properties/<property_name>
空の本文を持つ DELETE リクエストを使用してプロパティを削除することもできます。
/app/rest/vcs-roots/<vcsRootLocator>/properties/<property_name>
同様に、GET/PUT を使用して、フィールド値(id、name、project — 後者は VCS ルートを特定のプロジェクトに関連付けるために ProjectLocator を受け入れます)を受信および更新できます。
/app/rest/vcs-roots/<vcsRootLocator>/<property_name>
/app/rest/vcs-roots/<vcsRootLocator>/<property_name>
VCS ルートインスタンスを一覧表示する
VCS ルートインスタンスを取得するには、次を使用します。
/app/rest/vcs-root-instances?locator=<vcsRootInstanceLocator>
vcsRootInstanceLocator は VcsRootInstanceLocator として入力されます。例: MyVCSRoot ID を持つ VCS ルートのすべてのインスタンスを取得するには、次を使用します。
/app/rest/vcs-root-instances?locator=vcsRoot:(id:MyVCSRoot)
コミット後のフック通知
コミットフックコンテキストからの新しいコミットについて TeamCity に通知するには、次を使用します。
/app/rest/vcs-root-instances/commitHookNotification?locator=<vcsRootInstanceLocator>
一致した VCS ルートインスタンスの変更のチェックをスケジュールし、実行されたアクションについてプレーンテキストの人間が読めるメッセージを返します。操作が成功した場合の HTTP レスポンス 202。