Azure devops 如何使用RESTAPI将azure DevOps构建定义源从azure repos更新到GitHub
我正在尝试使用RESTAPI在azure DevOps构建中将源代码从azure repos git更改为GitHub 这是我使用azure Devops构建定义rest api对azure repos的响应-get 如果我手动将源代码从azure repo更改为GitHub,这就是我为GitHub repo获得的json响应-Azure devops 如何使用RESTAPI将azure DevOps构建定义源从azure repos更新到GitHub,azure-devops,azure-pipelines,azure-devops-rest-api,build-definition,azure-repos,Azure Devops,Azure Pipelines,Azure Devops Rest Api,Build Definition,Azure Repos,我正在尝试使用RESTAPI在azure DevOps构建中将源代码从azure repos git更改为GitHub 这是我使用azure Devops构建定义rest api对azure repos的响应-get 如果我手动将源代码从azure repo更改为GitHub,这就是我为GitHub repo获得的json响应- "repository": { "properties": { "apiUrl"
"repository": {
"properties": {
"apiUrl": "https://api.github.com/repos/{github_id}/{repo_name}",
"branchesUrl": "https://api.github.com/repos/{github_id}/{repo_name}/branches",
"cloneUrl": "https://github.com/{github_id}/{repo_name}.git",
"connectedServiceId": "xxxxxxx",
"defaultBranch": "master",
"fullName": "{github_id}/{repo_name}",
"hasAdminPermissions": "True",
"isFork": "False",
"isPrivate": "False",
"lastUpdated": "10/16/2019 17:28:29",
"manageUrl": "https://github.com/{github_id}/{repo_name}",
"nodeId": "xxxxxx",
"ownerId": "xxxxx",
"orgName": "{github_id}",
"refsUrl": "https://api.github.com/repos/{github_id}/pyapp/git/refs",
"safeRepository": "{github_id}/pyapp",
"shortName": "{repo_name}",
"ownerAvatarUrl": "https://avatars2.githubusercontent.com/u/xxxxx?v=4",
"archived": "False",
"externalId": "xxxxxx",
"ownerIsAUser": "True",
"checkoutNestedSubmodules": "false",
"cleanOptions": "0",
"fetchDepth": "0",
"gitLfsSupport": "false",
"reportBuildStatus": "true",
"skipSyncSource": "false",
"labelSourcesFormat": "$(build.buildNumber)",
"labelSources": "0"
},
"id": "{github_id}/{repo_name}",
"type": "GitHub",
"name": "{github_id}/{repo_name}",
"url": "https://github.com/{github_id}/{repo_name}.git",
"defaultBranch": "master",
"clean": "false",
"checkoutSubmodules": false
我试图使用postman将azure repo更改为github,方法是复制github json响应主体并添加postman,然后尝试调用put-https://dev.azure.com/{org\u name}/{project\u name}/\u api/build/definitions/{build\u Id}?api版本=6.0
但这是行不通的
如何使用脚本或邮递员实现这一点?我错过了什么
如何使用脚本或邮递员实现这一点?我错过了什么
您可以复制getbuilddefinitionapi
的内容
以下是我的例子:
网址:
请求身体样本:
{
"process": {
"phases": [
{
"steps": [
],
"name": "Phase 1",
"refName": "Phase_1",
"condition": "succeeded()",
"target": {
"executionOptions": {
"type": 0
},
"allowScriptsAuthAccessOption": false,
"type": 1
},
"jobAuthorizationScope": "projectCollection",
"jobCancelTimeoutInMinutes": 1
}
],
"type": 1
},
"repository": {
"properties": {
"cleanOptions": "0",
"labelSources": "0",
"labelSourcesFormat": "$(build.buildNumber)",
"reportBuildStatus": "true",
"gitLfsSupport": "false",
"skipSyncSource": "false",
"checkoutNestedSubmodules": "false",
"fetchDepth": "0"
},
"id": "{github_id}/{repo_name}",
"type": "GitHub",
"name": "{github_id}/{repo_name}",
"url": "https://github.com/{github_id}/{repo_name}.git",
"defaultBranch": "master",
"clean": "false",
"checkoutSubmodules": false
},
"id": {DefinitionID},
"revision": {revisionID},
"name": "definitionCreatedByRESTAPI",
"type": "build",
"queueStatus": "enabled"
}
在Reuqest机构中,有以下要点:
“id”:{DefinitionID}
是必需的
“修订版”:{revisionID}
您需要输入有效的修订版。这非常重要
Azure管道->目标构建定义->历史记录
您需要计算有多少更新记录。正确的修订是总数+1
例如:在我的屏幕截图中,正确的修订是10(9+1=10
)
PUT https://dev.azure.com/{OrganizationName}/{ProjectName}/_apis/build/definitions/{DefinitionID}?api-version=5.0-preview.6
{
"process": {
"phases": [
{
"steps": [
],
"name": "Phase 1",
"refName": "Phase_1",
"condition": "succeeded()",
"target": {
"executionOptions": {
"type": 0
},
"allowScriptsAuthAccessOption": false,
"type": 1
},
"jobAuthorizationScope": "projectCollection",
"jobCancelTimeoutInMinutes": 1
}
],
"type": 1
},
"repository": {
"properties": {
"cleanOptions": "0",
"labelSources": "0",
"labelSourcesFormat": "$(build.buildNumber)",
"reportBuildStatus": "true",
"gitLfsSupport": "false",
"skipSyncSource": "false",
"checkoutNestedSubmodules": "false",
"fetchDepth": "0"
},
"id": "{github_id}/{repo_name}",
"type": "GitHub",
"name": "{github_id}/{repo_name}",
"url": "https://github.com/{github_id}/{repo_name}.git",
"defaultBranch": "master",
"clean": "false",
"checkoutSubmodules": false
},
"id": {DefinitionID},
"revision": {revisionID},
"name": "definitionCreatedByRESTAPI",
"type": "build",
"queueStatus": "enabled"
}