Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VSTS restapi-GIT-Get分支策略_Rest_Azure Devops - Fatal编程技术网

VSTS restapi-GIT-Get分支策略

VSTS restapi-GIT-Get分支策略,rest,azure-devops,Rest,Azure Devops,可以在VST中使用RESTAPI获取具有策略的(git)分支列表吗 如果分支被锁定,响应将返回,但如果它包含策略,则不会返回。您可以使用API获取包含所有具有策略的分支的列表 获取项目中策略配置的列表 样本响应: { "count": 3, "value": [ { "createdBy": { "id": "d6245f20-2af8-44f4-9451-8107cb2767db", "displayName": "Normal P

可以在VST中使用RESTAPI获取具有策略的(git)分支列表吗

如果分支被锁定,响应将返回,但如果它包含策略,则不会返回。

您可以使用API获取包含所有具有策略的分支的列表

获取项目中策略配置的列表

样本响应:

{
  "count": 3,
  "value": [
    {
      "createdBy": {
        "id": "d6245f20-2af8-44f4-9451-8107cb2767db",
        "displayName": "Normal Paulk",
        "uniqueName": "fabrikamfiber16@hotmail.com",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
      },
      "createdDate": "2015-02-23T12:51:06.85754Z",
      "isEnabled": true,
      "isBlocking": true,
      "isDeleted": false,
      "settings": {
        "requiredReviewerIds": [
          "1d1dad71-f27c-4370-810d-838ec41efd41",
          "13272ea3-92ef-46d1-b77e-608ebbf3428b"
        ],
        "filenamePatterns": [
          "*/API*.cs",
          "sql/tables/*"
        ],
        "addedFilesOnly": false,
        "message": null,
        "scope": [
          {
            "refName": "refs/heads/master",
            "matchKind": "Exact",
            "repositoryId": null
          },
          {
            "refName": "refs/heads/releases/",
            "matchKind": "Prefix",
            "repositoryId": null
          },
          {
            "refName": "refs/heads/adventureworks",
            "matchKind": "Exact",
            "repositoryId": "49c1d4d0-be28-4f20-9e0a-4ecfafc39257"
          }
        ]
      },
      "_links": {
        "self": {
          "href": "https://dev.azure.com/fabrikam/_apis/policy/configurations/17"
        },
        "policyType": {
          "href": "https://dev.azure.com/fabrikam/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/fd2167ab-b0be-447a-8ec8-39368250530e"
        }
      },
      "revision": 2,
      "id": 17,
      "url": "https://dev.azure.com/fabrikam/_apis/policy/configurations/17",
      "type": {
        "id": "fd2167ab-b0be-447a-8ec8-39368250530e",
        "url": "https://dev.azure.com/fabrikam/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/fd2167ab-b0be-447a-8ec8-39368250530e",
        "displayName": "Required reviewers"
      }
    },
    {
      "createdBy": {
        "id": "d6245f20-2af8-44f4-9451-8107cb2767db",
        "displayName": "Normal Paulk",
        "uniqueName": "fabrikamfiber16@hotmail.com",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
      },
      "createdDate": "2015-02-23T12:51:06.8887894Z",
      "isEnabled": true,
      "isBlocking": false,
      "settings": {
        "minimumApproverCount": 1,
        "creatorVoteCounts": false,
        "scope": [
          {
            "refName": "refs/heads/master",
            "matchKind": "Exact",
            "repositoryId": null
          }
        ]
      },
      "_links": {
        "self": {
          "href": "https://dev.azure.com/fabrikam/_apis/policy/configurations/18"
        },
        "policyType": {
          "href": "https://dev.azure.com/fabrikam/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/fa4e907d-c16b-4a4c-9dfa-4906e5d171dd"
        }
      },
      "revision": 1,
      "id": 18,
      "url": "https://dev.azure.com/fabrikam/_apis/policy/configurations/18",
      "type": {
        "id": "fa4e907d-c16b-4a4c-9dfa-4906e5d171dd",
        "url": "https://dev.azure.com/fabrikam/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/fa4e907d-c16b-4a4c-9dfa-4906e5d171dd",
        "displayName": "Minimum approval count"
      }
    },
    {
      "createdBy": {
        "id": "d6245f20-2af8-44f4-9451-8107cb2767db",
        "displayName": "Normal Paulk",
        "uniqueName": "fabrikamfiber16@hotmail.com",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
      },
      "createdDate": "2015-02-23T12:51:06.935666Z",
      "isEnabled": true,
      "isBlocking": false,
      "settings": {
        "buildDefinitionId": 5,
        "scope": [
          {
            "refName": "refs/heads/features/",
            "matchKind": "Prefix",
            "repositoryId": null
          }
        ]
      },
      "_links": {
        "self": {
          "href": "https://dev.azure.com/fabrikam/_apis/policy/configurations/19"
        },
        "policyType": {
          "href": "https://dev.azure.com/fabrikam/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/0609b952-1397-4640-95ec-e00a01b2c241"
        }
      },
      "revision": 1,
      "id": 19,
      "url": "https://dev.azure.com/fabrikam/_apis/policy/configurations/19",
      "type": {
        "id": "0609b952-1397-4640-95ec-e00a01b2c241",
        "url": "https://dev.azure.com/fabrikam/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/0609b952-1397-4640-95ec-e00a01b2c241",
        "displayName": "Build"
      }
    }
  ]
}
refName
scope
部分,您可以看到分支机构名称和策略,在
policyType
中,您可以获得一个链接


策略类型说明。

很可能是这样,除非您没有权限,否则到目前为止您尝试了什么?感谢Luke,我只尝试了REST API调用,例如…../\u API/git/repositories//refs?includeLinks=false&includestates=false“我应该有必要的权限,好的,但只是想看看是否有可能,看看一项政策是否适用于一个分支机构。
{
  "count": 3,
  "value": [
    {
      "createdBy": {
        "id": "d6245f20-2af8-44f4-9451-8107cb2767db",
        "displayName": "Normal Paulk",
        "uniqueName": "fabrikamfiber16@hotmail.com",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
      },
      "createdDate": "2015-02-23T12:51:06.85754Z",
      "isEnabled": true,
      "isBlocking": true,
      "isDeleted": false,
      "settings": {
        "requiredReviewerIds": [
          "1d1dad71-f27c-4370-810d-838ec41efd41",
          "13272ea3-92ef-46d1-b77e-608ebbf3428b"
        ],
        "filenamePatterns": [
          "*/API*.cs",
          "sql/tables/*"
        ],
        "addedFilesOnly": false,
        "message": null,
        "scope": [
          {
            "refName": "refs/heads/master",
            "matchKind": "Exact",
            "repositoryId": null
          },
          {
            "refName": "refs/heads/releases/",
            "matchKind": "Prefix",
            "repositoryId": null
          },
          {
            "refName": "refs/heads/adventureworks",
            "matchKind": "Exact",
            "repositoryId": "49c1d4d0-be28-4f20-9e0a-4ecfafc39257"
          }
        ]
      },
      "_links": {
        "self": {
          "href": "https://dev.azure.com/fabrikam/_apis/policy/configurations/17"
        },
        "policyType": {
          "href": "https://dev.azure.com/fabrikam/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/fd2167ab-b0be-447a-8ec8-39368250530e"
        }
      },
      "revision": 2,
      "id": 17,
      "url": "https://dev.azure.com/fabrikam/_apis/policy/configurations/17",
      "type": {
        "id": "fd2167ab-b0be-447a-8ec8-39368250530e",
        "url": "https://dev.azure.com/fabrikam/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/fd2167ab-b0be-447a-8ec8-39368250530e",
        "displayName": "Required reviewers"
      }
    },
    {
      "createdBy": {
        "id": "d6245f20-2af8-44f4-9451-8107cb2767db",
        "displayName": "Normal Paulk",
        "uniqueName": "fabrikamfiber16@hotmail.com",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
      },
      "createdDate": "2015-02-23T12:51:06.8887894Z",
      "isEnabled": true,
      "isBlocking": false,
      "settings": {
        "minimumApproverCount": 1,
        "creatorVoteCounts": false,
        "scope": [
          {
            "refName": "refs/heads/master",
            "matchKind": "Exact",
            "repositoryId": null
          }
        ]
      },
      "_links": {
        "self": {
          "href": "https://dev.azure.com/fabrikam/_apis/policy/configurations/18"
        },
        "policyType": {
          "href": "https://dev.azure.com/fabrikam/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/fa4e907d-c16b-4a4c-9dfa-4906e5d171dd"
        }
      },
      "revision": 1,
      "id": 18,
      "url": "https://dev.azure.com/fabrikam/_apis/policy/configurations/18",
      "type": {
        "id": "fa4e907d-c16b-4a4c-9dfa-4906e5d171dd",
        "url": "https://dev.azure.com/fabrikam/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/fa4e907d-c16b-4a4c-9dfa-4906e5d171dd",
        "displayName": "Minimum approval count"
      }
    },
    {
      "createdBy": {
        "id": "d6245f20-2af8-44f4-9451-8107cb2767db",
        "displayName": "Normal Paulk",
        "uniqueName": "fabrikamfiber16@hotmail.com",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
      },
      "createdDate": "2015-02-23T12:51:06.935666Z",
      "isEnabled": true,
      "isBlocking": false,
      "settings": {
        "buildDefinitionId": 5,
        "scope": [
          {
            "refName": "refs/heads/features/",
            "matchKind": "Prefix",
            "repositoryId": null
          }
        ]
      },
      "_links": {
        "self": {
          "href": "https://dev.azure.com/fabrikam/_apis/policy/configurations/19"
        },
        "policyType": {
          "href": "https://dev.azure.com/fabrikam/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/0609b952-1397-4640-95ec-e00a01b2c241"
        }
      },
      "revision": 1,
      "id": 19,
      "url": "https://dev.azure.com/fabrikam/_apis/policy/configurations/19",
      "type": {
        "id": "0609b952-1397-4640-95ec-e00a01b2c241",
        "url": "https://dev.azure.com/fabrikam/1be3fc5b-c58c-4173-8fd7-6647d11eccd1/_apis/policy/types/0609b952-1397-4640-95ec-e00a01b2c241",
        "displayName": "Build"
      }
    }
  ]
}