Build information: include all commit since previous release

Hi there,

We’d like to push build information for a package along with every release that’s created by our CI/CD system (CircleCI).

The build information should contain all the commits since the previous release, so that those commits can be included in the release note.

For example:

{
  "BuildUrl": "https://circleci.com/gh/OurOrg/OurRepo/12345",
  "BuildNumber": "12345",
  "Commits": [
    {
      "Comment": "[Developer 1] Making a change",
      "Id": "2bf2153a"
    },
    {
      "Comment": "[Developer 2] Making another change",
      "Id": "95f21cc3"
    }
  ],
  "VcsType": "Git",
  "VcsRoot": "git@github.com:OurOrg/OurRepo.git",
  "Branch": "main",
  "VcsCommitNumber": "95f21cc3",
  "BuildEnvironment": "CircleCI"
}

In order to generate the list of commits in this example, we need the VcsCommitNumber of the package in the previous release. Once we have that hash, we can easly fetch all the commit since then…

git log $vcsCommitNumber..HEAD

… and generate the Commits array in the JSON from that.

Getting release info via …

octo list-releases --server=$ourServer --apiKey=$apiKey --project=$project --outputFormat=Json

… is not sufficient, as it does not return build information of the package.

The CLI does not appear to have a get-build-information (or similar) command.

What is the recommended way to fetch the build information from the most recent release?

Any other guidance on how to produce the list of commits when pushing build information?

Thanks!
Max

2 Likes

Hey there Max! I wanted to get a little more info on what it is you’re trying to do. Is it the case that the build information you’re attempting to see isn’t being included because build information for packages that were uploaded were not included in releases and their associated build info isn’t being displayed?

Hi Shawn, thanks for the quick response!

Almost! :slight_smile: We intend to create a new package version on every commit to the main branch, and a release for that latest package version. So if all goes well, there’s a package and a release for every commit, and the build information for the package only contains a single commit (which is the commit that triggered the build).

However, if the build workflow fails for any reason - for example, after a bad merge - there won’t be package and there won’t be a release for the commit. In that case, we’d like to add the commit to the build information next time the build succeeds.

Or in other words: the build information of every package should contain all the commit that were pushed since the previous package/release (which most of the time is just a single commit, but not always).

Does that make sense?

Thanks!
Max

I think I’m following, but a call may help make sure we’re on the same page. Is that something you’d be up for?

Regards,

Shawn

Looks like it can’t be done through the CLI but we can retrieve the build information’s VcsCommitNumber from the /{baseSpaceId}/projects/{projectId}/releases API endpoint:

Thanks!

1 Like

Nice! Glad you were able to get it working, please let us know if we can be of further assistance.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.