0

I'm using the Azure CLI to query Azure DevOps pull requests.

E.g.:

az repos pr list --status completed

This returns data similar to:

[
  {
    "artifactId": null,
    "autoCompleteSetBy": null,
    "closedBy": null,
    "closedDate": "2023-02-11T01:13:31.341293+00:00",
    "codeReviewId": 12345,
    "commits": null,
    "completionOptions": {
      "autoCompleteIgnoreConfigIds": [],
      "bypassPolicy": null,
      "bypassReason": null,
      "deleteSourceBranch": null,
      "mergeCommitMessage": "Merged PR 12345",
      "mergeStrategy": "noFastForward",
      "squashMerge": null,
      "transitionWorkItems": true,
      "triggeredByAutoComplete": null
    }
  },
  {
    "artifactId": null,
    "autoCompleteSetBy": null,
    "closedBy": null,
    "closedDate": "2023-03-04T23:59:53.506941+00:00",
    "codeReviewId": 12346,
    "commits": null,
    "completionOptions": {
      "autoCompleteIgnoreConfigIds": [],
      "bypassPolicy": null,
      "bypassReason": null,
      "deleteSourceBranch": true,
      "mergeCommitMessage": "Merged PR 12346",
      "mergeStrategy": "noFastForward",
      "squashMerge": null,
      "transitionWorkItems": true,
      "triggeredByAutoComplete": null
    }
  }
]

I want to find just the items in the array that have completionOptions.deleteSourceBranch set to null.

I've tried setting --query to the following (I'm using PowerShell), but it always returns an empty array.

  • "[?!completionOptions.deleteSourceBranch]"
  • "[?completionOptions.deleteSourceBranch == null]"
  • "[?completionOptions.deleteSourceBranch != ``true``]"
  • "[?completionOptions.deleteSourceBranch == ``null``]"

Any suggestions?

β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
David Gardiner
  • 16,892
  • 20
  • 80
  • 117
  • Both `[?completionOptions.deleteSourceBranch == null]` and ```[?completionOptions.deleteSourceBranch == `null`]``` should work, purely JMESPath speaking. – β.εηοιτ.βε Apr 28 '23 at 06:45

0 Answers0