CoDe
CoDe

Reputation: 11146

How to get git commit notes between two Bamboo build

I'm trying to set up CI for Gradle based Android project with Bamboo. Tutorial here work just work great for successful build.

For release note following I figure out to get Git log between two revision number.

git log ${bamboo.repository.previous.revision.number}..${bamboo.repository.revision.number}

But how to get last successful build git_revision number & current one. Any suggestion ?

Upvotes: 2

Views: 2838

Answers (1)

Vidish Datta
Vidish Datta

Reputation: 192

This involves scripting and utilizing REST API of Bamboo https://docs.atlassian.com/bamboo/REST [Choose the version you are working with]

To get all the build results, you need to make a call to:

[GET] <basepath>/rest/api/latest/result/{projectKey}-{buildKey}

Where, basepath is http://myhost.com:8085 OR http://myhost.com:8085/bamboo Resulting in below:

{
"results": {
"size": 8,
"expand": "result",
"start-index": 0,
"max-result": 25,
"result": [
  {
    "link": {
      "href": "<basepath>/rest/api/latest/result/{projectKey}-{buildKey}-{buildNumber}",
      "rel": "self"
    },
    "plan": {
      "shortName": "xyz",
      "shortKey": "{buildKey}",
      "type": "chain",
      "enabled": true,
      "link": {
        "href": "<basepath>/rest/api/latest/plan/DS-ASVCCRED",
        "rel": "self"
      },
      "key": "{projectKey}-{buildKey}",
      "name": "ABCD",
      "planKey": {
        "key": "{projectKey}-{buildKey}"
      }
    },
    "buildResultKey": "{projectKey}-{buildKey}-{buildNumber}",
    "lifeCycleState": "Finished",
    "id": 198039818,
    "key": "{projectKey}-{buildKey}-{buildNumber}",
    "planResultKey": {
      "key": "{projectKey}-{buildKey}-{buildNumber}",
      "entityKey": {
        "key": "{projectKey}-{buildKey}"
      },
      "resultNumber": 45
    },
    "state": "Failed",
    "buildState": "Failed",
    "number": 45,
    "buildNumber": 45
  },

If JSON output is desired, just add Accept=application/json header while making a call.

This will return latest 25 build results in a sequence with the latest result being the first. You may go through this results and decide which two build results you are interested in.

Once you decide, you make additional calls to get change set (commit details) captured by bamboo for that particular build.

[GET] <basepath>/rest/api/latest/result/{projectKey}-{buildKey}/{buildNumber : ([0-9]+)|(latest)}?expand=changes

This will give you detailed commit description as below:

"changes": {
 "size": 3,
 "expand": "change",
 "change": [
  {
    "author": "1234",
    "changesetId": "7f76c41a7ff48f679a91d0fa2810ef3398121dc6"
  },
  {
    "author": "abcd",
    "changesetId": "104d8b7af9538599a02006005314033c8017e804"
  },
  {
    "author": "cdef",
    "changesetId": "d21aef9f3745257aa501425fc31ebd0c6b33f608"
  }
 ],
 "start-index": 0,
 "max-result": 3
},

And then you can perform

git log <changesetId>...<changesetId>

Upvotes: 1

Related Questions