Skip to content

Azure DevOps branch protection status #880

@sereth

Description

@sereth

Using Atlantis 0.10.2 with DevOps

In DevOps when branch protection is enabled for the target branch, the Atlantis status updates are not recognized by DevOps to fulfill the required status checks.

It looks like the status checks are currently being posted to the latest commit of the source branch of the pull request.

https://dev.azure.com/mplehmann/POC-Terraform/_apis/git/repositories/POC-Terraform/commits/fe9fb32bb9654b52b2e624d070fe0380c979ecc5/statuses?api-version=5.1

{
  "count": 2,
  "value": [
    {
      "id": 3117312,
      "state": "succeeded",
      "description": "1/1 projects planned successfully.",
      "context": {
        "name": "atlantis/plan",
        "genre": "Atlantis Bot"
      },
      "creationDate": "2019-12-11T05:55:47.03Z",
      "createdBy": {
        "displayName": "Atlantis Bot",
        "url": "https://spsprodcus3.vssps.visualstudio.com/A49a26c68-cf72-446b-b7e3-1d9548e6303b/_apis/Identities/94d969d0-336f-601e-a289-78e66a5f70ed",
        "_links": {
          "avatar": {
            "href": "https://dev.azure.com/mplehmann/_apis/GraphProfile/MemberAvatars/aad.OTRkOTY5ZDAtMzM2Zi03MDFlLWEyODktNzhlNjZhNWY3MGVk"
          }
        },
        "id": "94d969d0-336f-601e-a289-78e66a5f70ed",
        "uniqueName": "atlantis-bot@mplehmann.com",
        "imageUrl": "https://dev.azure.com/mplehmann/_api/_common/identityImage?id=94d969d0-336f-601e-a289-78e66a5f70ed",
        "descriptor": "aad.OTRkOTY5ZDAtMzM2Zi03MDFlLWEyODktNzhlNjZhNWY3MGVk"
      }
    },
    {
      "id": 3117304,
      "state": "pending",
      "description": "Plan in progress...",
      "context": {
        "name": "atlantis/plan",
        "genre": "Atlantis Bot"
      },
      "creationDate": "2019-12-11T05:51:44.44Z",
      "createdBy": {
        "displayName": "Atlantis Bot",
        "url": "https://spsprodcus3.vssps.visualstudio.com/A49a26c68-cf72-446b-b7e3-1d9548e6303b/_apis/Identities/94d969d0-336f-601e-a289-78e66a5f70ed",
        "_links": {
          "avatar": {
            "href": "https://dev.azure.com/mplehmann/_apis/GraphProfile/MemberAvatars/aad.OTRkOTY5ZDAtMzM2Zi03MDFlLWEyODktNzhlNjZhNWY3MGVk"
          }
        },
        "id": "94d969d0-336f-601e-a289-78e66a5f70ed",
        "uniqueName": "atlantis-bot@mplehmann.com",
        "imageUrl": "https://dev.azure.com/mplehmann/_api/_common/identityImage?id=94d969d0-336f-601e-a289-78e66a5f70ed",
        "descriptor": "aad.OTRkOTY5ZDAtMzM2Zi03MDFlLWEyODktNzhlNjZhNWY3MGVk"
      }
    }
  ]
}

In the Branches view, this does show the status information on the branch. However, the pull request doesn't recognize this as fulfilling the branch protection requirements. It looks like the status checks instead need to be posted to the pull request API URL. If I manually post the same status information to the pull request, it does pass the branch protection requirements.

https://dev.azure.com/mplehmann/POC-Terraform/_apis/git/repositories/POC-Terraform/pullRequests/9/statuses?api-version=5.1-preview.1

{
    "value": [
        {
            "id": 1,
            "state": "succeeded",
            "description": "1/1 projects planned successfully.",
            "context": {
                "name": "atlantis/plan",
                "genre": "Atlantis Bot"
            },
            "creationDate": "2019-12-11T06:30:27.5003658Z",
            "updatedDate": "2019-12-11T06:30:27.5003658Z",
            "createdBy": {
                "displayName": "Michael Lehmann",
                "url": "https://spsprodcus3.vssps.visualstudio.com/A49a26c68-cf72-446b-b7e3-1d9548e6303b/_apis/Identities/e6a43a8b-5325-4306-9944-7fd2b4ae168e",
                "_links": {
                    "avatar": {
                        "href": "https://dev.azure.com/mplehmann/_apis/GraphProfile/MemberAvatars/aad.MzczY2U2ODUtOWEyNS03NzY3LWE3YjQtMWRjODVkNTI1Yzdh"
                    }
                },
                "id": "e6a43a8b-5325-4306-9944-7fd2b4ae168e",
                "uniqueName": "mplehmann@outlook.com",
                "imageUrl": "https://dev.azure.com/mplehmann/_apis/GraphProfile/MemberAvatars/aad.MzczY2U2ODUtOWEyNS03NzY3LWE3YjQtMWRjODVkNTI1Yzdh",
                "descriptor": "aad.MzczY2U2ODUtOWEyNS03NzY3LWE3YjQtMWRjODVkNTI1Yzdh"
            }
        },
        {
            "id": 2,
            "state": "pending",
            "description": "apply pending.",
            "context": {
                "name": "atlantis/apply",
                "genre": "Atlantis Bot"
            },
            "creationDate": "2019-12-11T06:33:43.172303Z",
            "updatedDate": "2019-12-11T06:33:43.172303Z",
            "createdBy": {
                "displayName": "Michael Lehmann",
                "url": "https://spsprodcus3.vssps.visualstudio.com/A49a26c68-cf72-446b-b7e3-1d9548e6303b/_apis/Identities/e6a43a8b-5325-4306-9944-7fd2b4ae168e",
                "_links": {
                    "avatar": {
                        "href": "https://dev.azure.com/mplehmann/_apis/GraphProfile/MemberAvatars/aad.MzczY2U2ODUtOWEyNS03NzY3LWE3YjQtMWRjODVkNTI1Yzdh"
                    }
                },
                "id": "e6a43a8b-5325-4306-9944-7fd2b4ae168e",
                "uniqueName": "mplehmann@outlook.com",
                "imageUrl": "https://dev.azure.com/mplehmann/_apis/GraphProfile/MemberAvatars/aad.MzczY2U2ODUtOWEyNS03NzY3LWE3YjQtMWRjODVkNTI1Yzdh",
                "descriptor": "aad.MzczY2U2ODUtOWEyNS03NzY3LWE3YjQtMWRjODVkNTI1Yzdh"
            }
        }
    ],
    "count": 2
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions