azure-devopsazure-pipelines

Azure DevOps Rest API : Object "ID" scope


I've read the individual API documentation for the APIs I am using. However, it seems to lack some key information - unless I've missed it !?

Specifically around the "ID"s of objects and their scope. For example, for pull requests, repositories, queues ... the responses all include their parent PROJECT identity. Conversely, Pipelines, Runs, Timelines do not.

That leaves me to ponder whether the scope of the IDs and whether some are unique within a project or across multiple projects or not?

Example : Pipelines API Docs

Returns:

{
    "_links": {
        "self": {
            "href": "https://dev.azure.com/<organization>/########/_apis/pipelines/1234?revision=2"
        },
        "web": {
            "href": "https://dev.azure.com/<organization>/########/_build/definition?definitionId=1234"
        }
    },
    "url": "https://dev.azure.com/<organization>/########/_apis/pipelines/1234?revision=2",
    "id": 1234,
    "revision": 2,
    "name": "myPipeline",
    "folder": "\\"
}

Response Docs

So in the above, is Pipeline "1234" a unique ID only in the current project? across all projects in my organization ? across all of AZDO?

Obviously I could work this out by exporting data from all of my accounts and projects then analyzing the results ... but much prefer the official specification.

Appreciate it if anyone knows of documentation around this?


Solution

  • is Pipeline "1234" a unique ID only in the current project? across all projects in my organization ? across all of AZDO?

    Based on your description, you are using Rest API: Pipelines - List to list the Pipeline Definitions. The ID is Pipeline definition ID.

    The pipeline definition ID is an immutable ID, that is unique across all projects in single Azure DevOps organization. But there is currently no official documentation that directly states this

    For other IDs mentioned in the question(pull requests, repositories, queues), they are all unique across all projects in single Azure DevOps organization.

    These information are not explained in the API documentation. However, some IDs are mentioned in other Pipeline variable related documents.

    For example:

    Use predefined variables

    Build.Repository.ID : The unique identifier of the repository. This won't change, even if the name of the repository does.

    Run and build numbers

    Pipeline Run ID/Build Run ID: $(Build.BuildId) is an internal, immutable ID, also called the Run ID, that is unique across the Azure DevOps organization.

    I can fully understand your requirement. It would be more convenient if these information were stated directly in the API documentation or in a separate document. You can submit a feedback request via Feedback option to share your requirement about enhanced documentation.

    enter image description here