xo-energy / action-octopus-build-information

GitHub Action that generates build information for Octopus Deploy
ISC License
4 stars 4 forks source link

Deployment 'Changes' JSON has unexpected content, breaking previous deployment version detection #4

Closed wjrogers closed 4 years ago

wjrogers commented 4 years ago

Example JSON fragment from the deployments API query below. The extra array elements correspond to un-released versions of a package that used to be used in this project, but isn't any more. I'm not what this content is supposed to mean (I wasn't sure why it was an array in the first place), but I think it can be worked around.

Use a heuristic to decide which element to use as the previously deployed version/commit, and add a way to explicitly name the package to use as the previous version source.

{
  "ItemType": "Deployment",
  "TotalResults": 9,
  "ItemsPerPage": 1,
  "NumberOfPages": 9,
  "LastPageNumber": 8,
  "Items": [
    {
      "Id": "Deployments-1100",
      "ReleaseId": "Releases-962",
      "ChannelId": "Channels-62",
      "DeploymentProcessId": "deploymentprocess-Projects-62-s-11-J3EZX",
      "Changes": [
        {
          "Version": "2.0.4",
          "ReleaseNotes": null,
          "BuildInformation": [],
          "WorkItems": [],
          "Commits": []
        },
        {
          "Version": "2.0.5",
          "ReleaseNotes": null,
          "BuildInformation": [],
          "WorkItems": [],
          "Commits": []
        },
        {
          "Version": "2.0.6",
          "ReleaseNotes": null,
          "BuildInformation": [],
          "WorkItems": [],
          "Commits": []
        },
        {
          "Version": "2.0.7",
          "ReleaseNotes": null,
          "BuildInformation": [],
          "WorkItems": [],
          "Commits": []
        },
        {
          "Version": "2.0.8",
          "ReleaseNotes": null,
          "BuildInformation": [],
          "WorkItems": [],
          "Commits": []
        },
        {
          "Version": "2.0.12",
          "ReleaseNotes": null,
          "BuildInformation": [],
          "WorkItems": [],
          "Commits": []
        },
        {
          "Version": "2.0.13",
          "ReleaseNotes": null,
          "BuildInformation": [],
          "WorkItems": [],
          "Commits": []
        },
        {
          "Version": "2.0.14",
          "ReleaseNotes": null,
          "BuildInformation": [],
          "WorkItems": [],
          "Commits": []
        },
        {
          "Version": "2.1.0",
          "ReleaseNotes": null,
          "BuildInformation": [
            {
              "PackageId": "XO.Project.Scripts",
              "Version": "2.1.0",
              "BuildEnvironment": null,
              "BuildNumber": "131072981",
              "BuildUrl": "https://github.com/xo-energy/XO.Project/actions/runs/131072981",
              "Branch": null,
              "VcsType": "Git",
              "VcsRoot": "https://github.com/xo-energy/XO.Project",
              "VcsCommitNumber": "8e63f87f246f1661cb3694e2028ffaad4ea12ebf",
              "VcsCommitUrl": null,
              "WorkItems": [],
              "Commits": []
            },
            {
              "PackageId": "XO.Project",
              "Version": "2.1.0",
              "BuildEnvironment": null,
              "BuildNumber": "131072981",
              "BuildUrl": "https://github.com/xo-energy/XO.Project/actions/runs/131072981",
              "Branch": null,
              "VcsType": "Git",
              "VcsRoot": "https://github.com/xo-energy/XO.Project",
              "VcsCommitNumber": "8e63f87f246f1661cb3694e2028ffaad4ea12ebf",
              "VcsCommitUrl": null,
              "WorkItems": [],
              "Commits": []
            }
          ],
          "WorkItems": [],
          "Commits": []
        }
      ]
    }
  ]
}