如何在两个Bamboo构建之间获取git commit notes

时间:2017-02-06 12:51:32

标签: android github bamboo

我正在尝试使用Bamboo为基于Gradle的Android项目设置CI。教程here工作非常适合成功构建。

对于发行说明,我想要在两个修订号之间获取Git日志。

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

但是如何获得最后成功的构建git_revision数字&目前的一个。 有什么建议吗?

1 个答案:

答案 0 :(得分:0)

这涉及编写和使用Bamboo的REST API https://docs.atlassian.com/bamboo/REST [选择您正在使用的版本]

要获得所有构建结果,您需要拨打以下电话:

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

其中,basepath为http://myhost.com:8085http://myhost.com:8085/bamboo 结果如下:

{
"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
  },

如果需要JSON输出,只需在拨打电话时添加Accept = application / json标头。

这将返回最新的25个构建结果,序列中最新结果为第一个。您可以浏览此结果并确定您感兴趣的两个构建结果。

一旦你做出决定,你就可以进行额外的调用,以获得由Bamboo捕获的特定版本的更改集(提交详细信息)。

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

这将为您提供详细的提交说明,如下所示:

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

然后你可以执行

git log <changesetId>...<changesetId>