Pull Request Statuses - Create
建立提取要求狀態。
狀態的唯一必要欄位是可唯一識別狀態的 Context.Name。
請注意,您可以在要求本文中指定 iterationId,在反覆項目上張貼狀態。
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/statuses?api-version=7.1
URI 參數
| 名稱 | 位於 | 必要 | 類型 | Description |
|---|---|---|---|---|
|
organization
|
path | True |
string |
Azure DevOps 組織的名稱。 |
|
pull
|
path | True |
integer (int32) |
提取要求的標識碼。 |
|
repository
|
path | True |
string |
提取要求目標分支的存放庫標識碼。 |
|
project
|
path |
string |
項目識別碼或項目名稱 |
|
|
api-version
|
query | True |
string |
要使用的 API 版本。 這應該設定為 『7.1』 以使用此版本的 API。 |
要求本文
| 名稱 | 類型 | Description |
|---|---|---|
| _links |
參考連結。 |
|
| context |
狀態的內容。 |
|
| createdBy |
建立狀態的身分識別。 |
|
| creationDate |
string (date-time) |
狀態的建立日期和時間。 |
| description |
string |
狀態描述。 通常描述狀態的目前狀態。 |
| id |
integer (int32) |
狀態標識碼。 |
| iterationId |
integer (int32) |
要與狀態產生關聯之反覆專案的標識碼。 最小值為 1。 |
| properties |
狀態的自定義屬性。 |
|
| state |
狀態的狀態。 |
|
| targetUrl |
string |
具有狀態詳細數據的 URL。 |
| updatedDate |
string (date-time) |
狀態的上次更新日期和時間。 |
回應
| 名稱 | 類型 | Description |
|---|---|---|
| 200 OK |
成功作業 |
安全性
oauth2
類型:
oauth2
Flow:
accessCode
授權 URL:
https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
權杖 URL:
https://app.vssps.visualstudio.com/oauth2/token?client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer
範圍
| 名稱 | Description |
|---|---|
| vso.code_write | 授與讀取、更新和刪除原始程式碼、存取認可、變更集、分支和其他版本控制成品的相關元數據的能力。 也授與建立和管理提取要求和程式代碼檢閱的能力,以及透過服務攔截接收版本控制事件的通知。 |
| vso.code_status | 授與讀取和寫入認可和提取要求狀態的能力。 |
範例
| On iteration |
| On pull request |
| With properties |
On iteration
範例要求
POST https://dev.azure.com/fabrikam/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/statuses?api-version=7.1
{
"iterationId": 1,
"state": "succeeded",
"description": "Sample status succeeded",
"context": {
"name": "sample-status-2",
"genre": "vsts-samples"
},
"targetUrl": "http://fabrikam-fiber-inc.com/CI/builds/1"
}
範例回覆
{
"iterationId": 1,
"id": 1,
"state": "succeeded",
"description": "Sample status succeeded",
"context": {
"name": "sample-status-2",
"genre": "vsts-samples"
},
"creationDate": "2017-09-19T14:50:26.4429056Z",
"updatedDate": "2017-09-19T14:50:26.4429056Z",
"createdBy": {
"id": "6f168adb-59d4-4fc0-be3b-fb21b939b2a6",
"displayName": "Normal Paulk",
"uniqueName": "fabrikamfiber16@hotmail.com",
"url": "https://dev.azure.com/fabrikam/_apis/Identities/6f168adb-59d4-4fc0-be3b-fb21b939b2a6",
"imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=6f168adb-59d4-4fc0-be3b-fb21b939b2a6"
},
"targetUrl": "http://fabrikam-fiber-inc.com/CI/builds/1",
"_links": {
"self": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/b92c8408-a0c9-4292-88af-bc005a1b8272/pullRequests/2/statuses/1"
},
"repository": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/b92c8408-a0c9-4292-88af-bc005a1b8272"
}
}
}
On pull request
範例要求
POST https://dev.azure.com/fabrikam/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/statuses?api-version=7.1
{
"state": "succeeded",
"description": "Sample status succeeded",
"context": {
"name": "sample-status-4",
"genre": "vsts-samples"
},
"targetUrl": "http://fabrikam-fiber-inc.com/CI/builds/1"
}
範例回覆
{
"id": 1,
"state": "succeeded",
"description": "Sample status succeeded",
"context": {
"name": "sample-status-4",
"genre": "vsts-samples"
},
"creationDate": "2017-09-19T14:50:25.1680228Z",
"updatedDate": "2017-09-19T14:50:25.1680228Z",
"createdBy": {
"id": "6f168adb-59d4-4fc0-be3b-fb21b939b2a6",
"displayName": "Normal Paulk",
"uniqueName": "fabrikamfiber16@hotmail.com",
"url": "https://dev.azure.com/fabrikam/_apis/Identities/6f168adb-59d4-4fc0-be3b-fb21b939b2a6",
"imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=6f168adb-59d4-4fc0-be3b-fb21b939b2a6"
},
"targetUrl": "http://fabrikam-fiber-inc.com/CI/builds/1",
"_links": {
"self": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/b92c8408-a0c9-4292-88af-bc005a1b8272/pullRequests/1/statuses/1"
},
"repository": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/b92c8408-a0c9-4292-88af-bc005a1b8272"
}
}
}
With properties
範例要求
POST https://dev.azure.com/fabrikam/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/statuses?api-version=7.1
{
"properties": {
"sampleId": 7,
"customInfo": "Custom status information",
"startedDateTime": {
"$type": "System.DateTime",
"$value": "2017-09-19T14:50:26.7410146Z"
},
"weight": {
"$type": "System.Double",
"$value": 1.75
},
"bytes": {
"$type": "System.Byte[]",
"$value": "dGhpcyBpcyBzYW1wbGUgYmFzZTY0IGVuY29kZWQgc3RyaW5n"
},
"globalId": {
"$type": "System.Guid",
"$value": "1e788cb9-9d3d-4dc6-ac05-822092d17f90"
}
},
"state": "succeeded",
"description": "Sample status succeeded",
"context": {
"name": "sample-status-1",
"genre": "vsts-samples"
},
"targetUrl": "http://fabrikam-fiber-inc.com/CI/builds/1"
}
範例回覆
{
"properties": {
"bytes": {
"$type": "System.Byte[]",
"$value": "dGhpcyBpcyBzYW1wbGUgYmFzZTY0IGVuY29kZWQgc3RyaW5n"
},
"customInfo": {
"$type": "System.String",
"$value": "Custom status information"
},
"globalId": {
"$type": "System.String",
"$value": "1e788cb99d3d4dc6ac05822092d17f90"
},
"sampleId": {
"$type": "System.Int32",
"$value": 7
},
"startedDateTime": {
"$type": "System.DateTime",
"$value": "2017-09-19T14:50:26.74Z"
},
"weight": {
"$type": "System.Double",
"$value": 1.75
}
},
"id": 1,
"state": "succeeded",
"description": "Sample status succeeded",
"context": {
"name": "sample-status-1",
"genre": "vsts-samples"
},
"creationDate": "2017-09-19T14:50:26.7780242Z",
"updatedDate": "2017-09-19T14:50:26.7780242Z",
"createdBy": {
"id": "6f168adb-59d4-4fc0-be3b-fb21b939b2a6",
"displayName": "Normal Paulk",
"uniqueName": "fabrikamfiber16@hotmail.com",
"url": "https://dev.azure.com/fabrikam/_apis/Identities/6f168adb-59d4-4fc0-be3b-fb21b939b2a6",
"imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=6f168adb-59d4-4fc0-be3b-fb21b939b2a6"
},
"targetUrl": "http://fabrikam-fiber-inc.com/CI/builds/1",
"_links": {
"self": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/b92c8408-a0c9-4292-88af-bc005a1b8272/pullRequests/3/statuses/1"
},
"repository": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/b92c8408-a0c9-4292-88af-bc005a1b8272"
}
}
}
定義
| 名稱 | Description |
|---|---|
|
Git |
這個類別包含服務/擴充功能張貼提取要求狀態的元數據。 狀態可以與提取要求或反覆項目相關聯。 |
|
Git |
可唯一識別狀態的狀態內容。 |
|
Git |
狀態的狀態。 |
|
Identity |
|
|
Properties |
類別會將屬性包表示為索引鍵/值組的集合。 接受 |
|
Reference |
表示 REST 參考連結集合的類別。 |
GitPullRequestStatus
這個類別包含服務/擴充功能張貼提取要求狀態的元數據。 狀態可以與提取要求或反覆項目相關聯。
| 名稱 | 類型 | Description |
|---|---|---|
| _links |
參考連結。 |
|
| context |
狀態的內容。 |
|
| createdBy |
建立狀態的身分識別。 |
|
| creationDate |
string (date-time) |
狀態的建立日期和時間。 |
| description |
string |
狀態描述。 通常描述狀態的目前狀態。 |
| id |
integer (int32) |
狀態標識碼。 |
| iterationId |
integer (int32) |
要與狀態產生關聯之反覆專案的標識碼。 最小值為 1。 |
| properties |
狀態的自定義屬性。 |
|
| state |
狀態的狀態。 |
|
| targetUrl |
string |
具有狀態詳細數據的 URL。 |
| updatedDate |
string (date-time) |
狀態的上次更新日期和時間。 |
GitStatusContext
可唯一識別狀態的狀態內容。
| 名稱 | 類型 | Description |
|---|---|---|
| genre |
string |
狀態的內容類型。 通常產生狀態的服務/工具名稱可以是空的。 |
| name |
string |
狀態的名稱識別碼不可為 Null 或空白。 |
GitStatusState
狀態的狀態。
| 值 | Description |
|---|---|
| error |
發生錯誤的狀態。 |
| failed |
狀態失敗。 |
| notApplicable |
狀態不適用於目標物件。 |
| notSet |
未設定狀態。 默認狀態。 |
| pending |
狀態擱置中。 |
| succeeded |
狀態成功。 |
IdentityRef
| 名稱 | 類型 | Description |
|---|---|---|
| _links |
此欄位包含圖表主旨的相關零或更多有趣連結。 您可以叫用這些連結,以取得此圖表主題的其他關聯性或更詳細的資訊。 |
|
| descriptor |
string |
描述元是在系統執行時參考圖表主旨的主要方式。 此欄位會唯一識別帳戶和組織之間的相同圖表主題。 |
| directoryAlias |
string |
已淘汰 - 查詢 IdentityRef “_links” 字典中參考的 Graph 使用者,即可擷取 |
| displayName |
string |
這是圖形主體的非唯一顯示名稱。 若要變更此欄位,您必須在來源提供者中變更其值。 |
| id |
string |
|
| imageUrl |
string |
已淘汰 - 可在 IdentityRef “_links” 字典的 “avatar” 專案中取得 |
| inactive |
boolean |
已淘汰 - 可藉由查詢 GraphUser “_links” 字典的 “membershipState” 專案中參考的 Graph 成員資格狀態來擷取 |
| isAadIdentity |
boolean |
已淘汰 - 可以從描述元的主體類型推斷 (Descriptor.IsAadUserType/Descriptor.IsAadGroupType) |
| isContainer |
boolean |
已淘汰 - 可以從描述元的主體類型推斷 (Descriptor.IsGroupType) |
| isDeletedInOrigin |
boolean |
|
| profileUrl |
string |
已淘汰 - 未在 ToIdentityRef 的大部分預先存在實作中使用 |
| uniqueName |
string |
已淘汰 - 請改用 Domain+PrincipalName |
| url |
string |
此 URL 是此圖表主體來源資源的完整路由。 |
PropertiesCollection
類別會將屬性包表示為索引鍵/值組的集合。 接受 DBNull 以外的所有基本類型值(任何具有 TypeCode != TypeCode.Object的類型)。 Byte[]、Int32、Double、DateType 和 String 類型的值會保留其類型,其他基本類型會重新調整為 String。 Byte[] 預期為base64編碼字串。
| 名稱 | 類型 | Description |
|---|---|---|
| count |
integer (int32) |
集合中的屬性計數。 |
| item |
object |
|
| keys |
string[] |
集合中的索引鍵集合。 |
| values |
string[] |
集合中的值集合。 |
ReferenceLinks
表示 REST 參考連結集合的類別。
| 名稱 | 類型 | Description |
|---|---|---|
| links |
object |
連結的只讀檢視。 因為參考連結是只讀的,所以我們只想要將其公開為只讀。 |