【问题标题】:How to create ADO REPO with 'develop' branch as default using ADO API calls如何使用 ADO API 调用默认创建具有“开发”分支的 ADO REPO
【发布时间】:2022-01-08 23:22:33
【问题描述】:

我正在使用 ADO API 调用为使用 ADO API 的分支创建 REPO 和相关治理。看看我的 repo.yml 有所有 API 细节。 在创建回购时;我从中得到“master”和“develop”分支。但是主分支设置为默认分支。我想将开发分支设为默认。我怎样才能做到这一点?什么是正确的 API?

---
branches:
  -
    master:
      bypass: false
      content:
        - placeholder.txt
      policies:
        -
          merge:
            id: -3
            isBlocking: true
            isDeleted: false
            isEnabled: true
            settings:
              allowNoFastForward: true
              allowRebase: false
              allowRebaseMerge: true
              allowSquash: false
              scope:
                -
                  matchKind: Exact
                  refName: refs/heads/master
                  repositoryId: ~
              useSquashMerge: true
            type: ~
            url: ""
        -
          approval_count:
            id: -2
            isBlocking: true
            isDeleted: false
            isEnabled: true
            settings:
              allowDownvotes: false
              creatorVoteCounts: false
              minimumApproverCount: 1
              resetOnSourcePush: true
              scope:
                -
                  matchKind: Exact
                  refName: refs/heads/master
                  repositoryId: ~
            type: ~
            url: ""
        -
          build:
            id: -250
            isBlocking: true
            isDeleted: false
            isEnabled: true
            settings:
              buildDefinitionId: 1
              displayName: "Main Pipeline"
              manualQueueOnly: false
              queueOnSourceUpdateOnly: true
              scope:
                -
                  matchKind: Exact
                  refName: refs/heads/master
                  repositoryId: ~
              validDuration: 0
            type: ~
            url: ""
        -
          example:
            id: -4
            isBlocking: true
            isDeleted: false
            isEnabled: true
            settings:
              addedFilesOnly: false
              filenamePatterns: []
              ignoreIfSourceIsInScope: false
              message: ""
              requiredReviewerIds: 1
              scope:
                -
                  matchKind: Exact
                  refName: refs/heads/master
                  repositoryId: ~
            type: ~
            url: ""
  -
    develop:
      bypass: true
      content:
        - azure-pipelines.yml
        - placeholder.txt
        - params.json
        - .gitignore
      policies: []
organization_url: "https://xxxx.visualstudio.com/"
project: CloudTeam

【问题讨论】:

    标签: azure-devops azure-devops-rest-api


    【解决方案1】:

    我会考虑进行后续调用,将分支设置为develop,使用

    PATCH https://dev.azure.com/yourOrgName/yourProject/_apis/git/repositories/yourRepoId?api-version=6.0
    

    和请求正文

    {
      "defaultBranch": "refs/heads/develop"
    }
    

    【讨论】:

      猜你喜欢
      • 2021-08-15
      • 2011-09-10
      • 1970-01-01
      • 2021-03-09
      • 1970-01-01
      • 2012-03-21
      • 1970-01-01
      • 2021-03-15
      • 1970-01-01
      相关资源
      最近更新 更多