'Change Azure DevOps Organization setting through REST API

I've been going through the Azure DevOps API docs, but I can't seem to find an endpoint for changing organization settings through the REST API.

More specifically, I'm trying to change the Pipeline settings. For a project, this exists, but it seems at Organization level it is not possible.

enter image description here

Am I right this is not feasible through the REST API? Would this be possible via the Azure DevOps CLI?



Solution 1:[1]

After my investigation, there is no DevOps Rest API in the official document as you said. As a suggestion, you could submit a suggestion ticket to suggest the feature on: https://developercommunity.visualstudio.com/report?space=21&entry=suggestion.

However, we can use this API in F12 to change the organization pipeline general settings as a workaround.

POST https://dev.azure.com/{org}/_apis/Contribution/HierarchyQuery?api-version=5.0-preview.1
content-type: application/json
request body:
{
  "contributionIds": [
    "ms.vss-build-web.pipelines-org-settings-data-provider"
  ],
  "dataProviderContext": {
    "properties": {
      "badgesArePublic": "true",
      "sourcePage": {
        "url": "https://dev.azure.com/{org_name}/_settings/pipelinessettings",
        "routeId": "ms.vss-admin-web.collection-admin-hub-route",
        "routeValues": {
          "adminPivot": "pipelinessettings",
          "controller": "ContributedPage",
          "action": "Execute",
          "serviceHost": "{please check it in F12 when changing settings}"
        }
      }
    }
  }
}

Names of these settings:

badgesArePublic: Disable anonymous access to badges

enforceSettableVar: Limit variables that can be set at queue time

enforceJobAuthScope: Limit job authorization scope to current project for non-release pipelines

enforceJobAuthScopeForReleases: Limit job authorization scope to current project for release pipelines

enforceReferencedRepoScopedToken: Protect access to repositories in YAML pipelines

disableStageChooser: Disable stage chooser

Solution 2:[2]

API is available now: https://docs.microsoft.com/en-us/rest/api/azure/devops/build/general-settings/update?view=azure-devops-rest-6.0

I am able to update build general-settings through below api:

curl -u user:password --location --request PATCH 'https://dev.azure.com/{organization}/{project}/_apis/build/generalsettings?api-version=6.0-preview.1' --data '{"enforceReferencedRepoScopedToken":false,"statusBadgesArePrivate":false,"enforceSettableVar":false,"enforceJobAuthScope":false,"enforceJobAuthScopeForReleases":false,"publishPipelineMetadata":false}' --header "Content-type: application/json"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 unknown
Solution 2 PALLAV GUPTA