I am using the azure devops rest api to extract a list of builds as follows

https://dev.azure.com/D{my Org}/{my project}/_apis/build/builds?api-version=5.1

this returns all the builds in the JSON extract correctly but only builds that have been automatically initiated by a merge to master include the build message details , included inside the trigger.info attribute of the json file.

builds that are manually fired do not have any trigger info at all

Example - see screen shot of 2 builds one fired automatically one manually

#sql-data-warehouse-20240229.3 • Merged PR 1082: FF-654: modified email body (automatically triggered)

Auto triggered creates results with a ci.message part included in the "triggerinfo" attribute in the json body

       "triggerInfo": {
            "ci.sourceBranch": "refs/heads/master",
            "ci.sourceSha": "4040759cee517f35abf2bf1b107e033e7c33bc93",
            **"ci.message": "Merged PR 1082: FF-654: modified email body",**
            "ci.triggerRepository": "d5b5f4d1-49b9-4457-b934-6dffc6932ce7"
        },
        "id": 5545,
        "buildNumber": "sql-data-warehouse-20240229.3",

manually triggered

#sql-data-warehouse-20240229.2 • Merged PR 1073: FF-654: scripts for dqm alert when fx traded (manually triggered)

        "triggerInfo": {},
        "id": 5537,
        "buildNumber": "sql-data-warehouse-20240229.2",

Json does not return anything in the "triggerinfo" attribute

What I am trying to do is extract a list of all builds including the message note created at build time for all builds.

I have tried a variety of API options and cannot locate the information I am after

1

There are 1 best solutions below

2
Ziyang Liu-MSFT On

This is the expected behavior, not all builds have ci.message. triggerInfo is the sourceprovider-specific information about what triggered the build. The reason that build is triggered is different, and the corresponding triggerInfo is also different.

enter image description here

You can refer to the following examples.

  • "reason": "manual"
            "triggerInfo": {},
  • "reason": "individualCI"
            "triggerInfo": {
                "ci.sourceBranch": "main",
                "ci.sourceSha": "***",
                "ci.message": "Set up CI with Azure Pipelines"
            },
  • "reason": "pullRequest"
            "triggerInfo": {
                "pr.number": "93",
                "pr.isFork": "False",
                "pr.triggerRepository": "***",
                "pr.triggerRepository.Type": "TfsGit"
            },

  • "reason": "resourceTrigger"
            "triggerInfo": {
                "artifactType": "Pipeline",
                "alias": "myresourcevars",
                "projectId": "***",
                "pipelineTriggerType": "PipelineCompletion",
                "source": "MainPipeline",
                "pipelineId": "***",
                "version": "20240228.2"
            },
  • "reason": "schedule"
            "triggerInfo": {
                "scheduleName": "Trigger every 1 minutes test"
            },