如何获取travis-ci请求的状态

时间:2016-07-05 03:18:48

标签: travis-ci

我想在存储库的主分支上触发travis运行。这可以按照travis docs中的说明正常工作,但后来我不知道如何获得执行的状态。请求返回一些ID,但似乎都不是请求ID。

$ body='{
"request": {
  "branch":"master"
}}'

$ curl -s -X POST   -H "Content-Type: application/json"   -H "Accept: application/json"   -H "Travis-API-Version: 3"   -H "Authorization: token $TOKEN"   -d "$body"   https://api.travis-ci.org/repo/snapcore%2Fsnapcraft/requests                                                                                                           
{
  "@type": "pending",
  "remaining_requests": 9,
  "repository": {
    "@type": "repository",
    "@href": "/repo/6402925",
    "@representation": "minimal",
    "id": 6402925,
    "name": "snapcraft",
    "slug": "snapcore/snapcraft"
  },
  "request": {
    "repository": {
      "id": 45199136,
      "owner_name": "snapcore",
      "name": "snapcraft"
    },
    "user": {
      "id": 38186
    },
    "message": null,
    "branch": "master",
    "config": {
    }
  },
  "resource_type": "request"
}

我可以使用此端点获取所有请求:https://docs.travis-ci.com/api?http#requests 但后来我必须找到我的要求,而且我不知道如何识别它。

1 个答案:

答案 0 :(得分:0)

响应中还应该包含request.id

{
  "@type": "pending",
  "remaining_requests": 49,
  "repository": {
    "@type": "repository",
    "@href": "/repo/7181875",
    "@representation": "minimal",
    "id": 7181875,
    "name": "repo_name",
    "slug": "repo_user/repo_name"
  },
  "request": {
    "repository": {
      "id": 160982756,
      "owner_name": "repo_owner",
      "name": "repo_name"
    },
    "user": {
      "id": 919859
    },
    "id": 160105240,   # <-- this is the request ID that can be used in /request/#id
    "message": null,
    "branch": "master",
    "config": {
    }
  },
  "resource_type": "request"
}

您发布的内容似乎缺少此内容。要么在此期间添加了它,要么就以某种方式对您迷路了。