Pull Request Statuses - Create
建立提取要求狀態。
狀態的唯一必要欄位是 Context.Name 唯一識別狀態。
請注意,您可以在要求本文中指定 iterationId,以在反復專案上張貼狀態。
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/statuses?api-version=4.1-preview.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 版本。 這應該設定為 '4.1-preview.1' 以使用此版本的 API。 |
要求本文
| 名稱 | 類型 | Description |
|---|---|---|
| _links |
參考連結。 |
|
| context |
狀態的內容。 |
|
| createdBy |
建立狀態的身分識別。 |
|
| creationDate |
string |
狀態的建立日期和時間。 |
| description |
string |
狀態原因。 通常描述狀態的目前狀態。 |
| id |
integer |
狀態識別碼。 |
| iterationId |
integer |
要與狀態產生關聯之反復專案的識別碼。 最小值為 1。 |
| properties |
狀態的自訂屬性。 |
|
| state |
狀態的狀態。 |
|
| targetUrl |
string |
具有狀態詳細資料的 URL。 |
| updatedDate |
string |
狀態的上次更新日期和時間。 |
回應
| 名稱 | 類型 | 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=4.1-preview.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=4.1-preview.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=4.1-preview.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 |
狀態的建立日期和時間。 |
| description |
string |
狀態原因。 通常描述狀態的目前狀態。 |
| id |
integer |
狀態識別碼。 |
| iterationId |
integer |
要與狀態產生關聯之反復專案的識別碼。 最小值為 1。 |
| properties |
狀態的自訂屬性。 |
|
| state |
狀態的狀態。 |
|
| targetUrl |
string |
具有狀態詳細資料的 URL。 |
| updatedDate |
string |
狀態的上次更新日期和時間。 |
GitStatusContext
可唯一識別狀態的狀態內容。
| 名稱 | 類型 | Description |
|---|---|---|
| genre |
string |
狀態的內容類型。 通常產生狀態的服務/工具名稱可以是空的。 |
| name |
string |
狀態的名稱識別碼不可以是 Null 或空白。 |
GitStatusState
狀態的狀態。
| 值 | Description |
|---|---|
| error |
發生錯誤的狀態。 |
| failed |
狀態失敗。 |
| notApplicable |
狀態不適用於目標物件。 |
| notSet |
未設定狀態。 預設狀態。 |
| pending |
狀態擱置中。 |
| succeeded |
狀態成功。 |
IdentityRef
| 名稱 | 類型 | Description |
|---|---|---|
| _links |
此欄位包含有關圖表主旨的零個或多個有趣連結。 您可以叫用這些連結來取得其他關聯性,或取得此圖表主體的詳細資訊。 |
|
| descriptor |
string |
描述項是在系統執行時參考圖形主旨的主要方式。 此欄位可唯一識別帳戶和組織之間的相同圖表主旨。 |
| directoryAlias |
string |
|
| displayName |
string |
這是圖表主旨的非唯一顯示名稱。 若要變更此欄位,您必須在來源提供者中變更其值。 |
| id |
string |
|
| imageUrl |
string |
|
| inactive |
boolean |
|
| isAadIdentity |
boolean |
|
| isContainer |
boolean |
|
| profileUrl |
string |
|
| uniqueName |
string |
|
| url |
string |
此 URL 是此圖表主體來源資源的完整路由。 |
PropertiesCollection
類別會將屬性包表示為索引鍵/值組的集合。 所有基本類型的值都會 (接受任何具有 TypeCode != TypeCode.Object) DBNull 的型別。 Byte[]、Int32、Double、DateType 和 String 類型的值會保留其類型,其他基本類型則會重新調整為 String。 Byte[] 預期為 base64 編碼字串。
| 名稱 | 類型 | Description |
|---|---|---|
| count |
integer |
集合中的屬性計數。 |
| item |
object |
|
| keys |
string[] |
集合中的索引鍵集合。 |
| values |
string[] |
集合中的值集合。 |
ReferenceLinks
表示 REST 參考連結集合的類別。
| 名稱 | 類型 | Description |
|---|---|---|
| links |
object |
連結的唯讀檢視。 因為參考連結是唯讀的,所以我們只想要將它們公開為唯讀。 |