构建
2017-02-21 本文已影响0人
SetZero
构建
1、获取仓库构建信息
- 获取仓库构建信息需要仓库拥有者帐号和仓库名。
-
若该公共仓库已设置响应事件,是不需要用户授权验证的。
-
若该公共仓库未设置响应事件,是需要用户授权验证的,但最终返回状态码为404。
-
若该私有仓库已设置响应事件,是需要用户授权验证的。
-
若该私有仓库未设置响应事件,是需要用户授权验证的,但最终返回状态码为404。
-
请求方式
GET /api/repos/{owner}/{name}/builds
- 例子(仓库
demo
为私有仓库)
curl -X GET -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZXh0IjoiYWRtaW51c2VyIiwidHlwZSI6InVzZXIifQ.LNh2Yi-bA7kh56ZLKrTi2GzMIcDkaMVBc8-I9o_UoLU" "http://192.168.58.13/api/repos/adminuser/demo/builds"
- 响应
Status: 200 OK
Content-Type: application/json
[
{
"id": 24,
"number": 2,
"parent": 0,
"event": "push",
"status": "success",
"enqueued_at": 1487573783,
"created_at": 1487573783,
"started_at": 1487573783,
"finished_at": 1487573803,
"deploy_to": "",
"commit": "5f077cc8e208885f8595b3c03131f0707e65af6d",
"branch": "master",
"ref": "refs/heads/master",
"refspec": "",
"remote": "",
"title": "",
"message": "fix path\n",
"timestamp": 1487573783,
"author": "adminuser",
"author_avatar": "https://secure.gravatar.com/avatar/0f656b0b09d16bafa95064e7e9bd83bc",
"author_email": "ziling.zhong@hand-china.com",
"link_url": "http://192.168.56.21:10080/adminuser/demo/compare/c9ad367cac7c3bf505bd3f93f1c1caac2015f5d3...5f077cc8e208885f8595b3c03131f0707e65af6d",
"signed": false,
"verified": false
},
{
"id": 23,
"number": 1,
"parent": 0,
"event": "push",
"status": "failure",
"enqueued_at": 1487573720,
"created_at": 1487573720,
"started_at": 1487573720,
"finished_at": 1487573756,
"deploy_to": "",
"commit": "c9ad367cac7c3bf505bd3f93f1c1caac2015f5d3",
"branch": "master",
"ref": "refs/heads/master",
"refspec": "",
"remote": "",
"title": "",
"message": "add base\n",
"timestamp": 1487573720,
"author": "adminuser",
"author_avatar": "https://secure.gravatar.com/avatar/0f656b0b09d16bafa95064e7e9bd83bc",
"author_email": "ziling.zhong@hand-china.com",
"link_url": "http://192.168.56.21:10080/adminuser/demo/compare/e28795b01e9af7ec513ae9c8160be9c2b5899436...c9ad367cac7c3bf505bd3f93f1c1caac2015f5d3",
"signed": false,
"verified": false
}
]
2、获取指定构建信息
- 获取指定构建信息需要仓库拥有者帐号、仓库名和第几次构建的编号,且该仓库已设置响应事件,设置响应事件后是无法访问的。
- 公共仓库不需要用户授权验证。
- 请求方式
GET /api/repos/{owner}/{name}/builds/{number}
- 例子
curl -X GET -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZXh0IjoiYWRtaW51c2VyIiwidHlwZSI6InVzZXIifQ.p2KhqJ-hl7lVdWawKtowBucWRANmYLv6ZqY64-gE660" "http://192.168.56.21/api/repos/adminuser/demo/builds/1"
- 响应
Status: 200 OK
Content-Type: application/json
{
"id": 23,
"number": 1,
"parent": 0,
"event": "push",
"status": "failure",
"enqueued_at": 1487573720,
"created_at": 1487573720,
"started_at": 1487573720,
"finished_at": 1487573756,
"deploy_to": "",
"commit": "c9ad367cac7c3bf505bd3f93f1c1caac2015f5d3",
"branch": "master",
"ref": "refs/heads/master",
"refspec": "",
"remote": "",
"title": "",
"message": "add base\n",
"timestamp": 1487573720,
"author": "adminuser",
"author_avatar": "https://secure.gravatar.com/avatar/0f656b0b09d16bafa95064e7e9bd83bc",
"author_email": "ziling.zhong@hand-china.com",
"link_url": "http://192.168.56.21:10080/adminuser/demo/compare/e28795b01e9af7ec513ae9c8160be9c2b5899436...c9ad367cac7c3bf505bd3f93f1c1caac2015f5d3",
"signed": false,
"verified": false,
"jobs": [
{
"id": 23,
"number": 1,
"error": "",
"status": "failure",
"exit_code": 1,
"enqueued_at": 1487573720,
"started_at": 1487573720,
"finished_at": 1487573756,
"environment": {}
}
]
}
3、重新构建
- 重新构建仓库需要仓库拥有者帐号、仓库名第几次构建的编号,且该仓库已设置响应事件,未设置响应事件后是无法访问的。
- 需要用户授权验证。
- 请求方式
POST /api/repos/{owner}/{name}/builds/{number}
- 例子
curl -X POST -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZXh0IjoiYWRtaW51c2VyIiwidHlwZSI6InVzZXIifQ.p2KhqJ-hl7lVdWawKtowBucWRANmYLv6ZqY64-gE660" "http://192.168.56.21/api/repos/adminuser/demo/builds/1"
- 响应
Status: 200 OK
Content-Type: application/json
{
"id": 23,
"number": 1,
"parent": 0,
"event": "push",
"status": "pending",
"enqueued_at": 1487574780,
"created_at": 1487573720,
"started_at": 0,
"finished_at": 0,
"deploy_to": "",
"commit": "c9ad367cac7c3bf505bd3f93f1c1caac2015f5d3",
"branch": "master",
"ref": "refs/heads/master",
"refspec": "",
"remote": "",
"title": "",
"message": "add base\n",
"timestamp": 1487573720,
"author": "adminuser",
"author_avatar": "https://secure.gravatar.com/avatar/0f656b0b09d16bafa95064e7e9bd83bc",
"author_email": "ziling.zhong@hand-china.com",
"link_url": "http://192.168.56.21:10080/adminuser/demo/compare/e28795b01e9af7ec513ae9c8160be9c2b5899436...c9ad367cac7c3bf505bd3f93f1c1caac2015f5d3",
"signed": false,
"verified": false
}
4、获取构建日志
- 返回指定构建编号的工作日志(构建步骤)。
-
获取构建日志需要仓库拥有者帐号、仓库名第几次构建的编号,且该仓库已设置响应事件,未设置响应事件后是无法访问的。
-
公共仓库不需要用户授权验证。
-
请求方式
GET /api/repos/{owner}/{name}/logs/{number}/{job}
- 例子
curl -X GET "http://192.168.56.21/api/repos/adminuser/demo/logs/2/1"
- 响应
Status: 200 OK
Content-Type: application/json
[
{
"proc": "postgres",
"pos": 0,
"out": "The files belonging to this database system will be owned by user \"postgres\"."
},
{
"proc": "postgres",
"pos": 1,
"out": "This user must also own the server process."
},
{
"proc": "postgres",
"pos": 2
},
{
"proc": "postgres",
"pos": 3,
"out": "The database cluster will be initialized with locale \"en_US.utf8\"."
},
. . . . . .
{}
]
5、取消指定的构建
- 取消构建需要仓库拥有者帐号、仓库名第几次构建的编号,且该仓库已设置响应事件,未设置响应事件后是无法访问的。
-
需要用户授权验证。
-
请求方式
DELETE /api/repos/{owner}/{name}/builds/{number}/{job}
- 例子
curl -X DELETE -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZXh0IjoiYWRtaW51c2VyIiwidHlwZSI6InVzZXIifQ.p2KhqJ-hl7lVdWawKtowBucWRANmYLv6ZqY64-gE660" "http://192.168.56.21/api/repos/adminuser/demo/builds/2/1"
- 响应
Status: 204
Content-Type: text/plain; charset=utf-8
6、查询当前正在构建仓库信息
- 需要用户授权验证。
- 请求方式
GET /api/builds
- 例子
curl -X GET -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZXh0IjoiYWRtaW51c2VyIiwidHlwZSI6InVzZXIifQ.HvnfTlVqdGneN76HqvluLQSs9LlGqCImBalrppIK7Sk" "http://192.168.56.21/api/builds"
- 响应
Status: 200
Content-Type: application/json; charset=utf-8
[
{
"owner": "adminuser",
"name": "drone-test",
"full_name": "adminuser/drone-test",
"number": 2,
"event": "push",
"status": "running",
"created_at": 1487855200,
"started_at": 1487855201,
"commit": "ec369afe67307c9f4bee5a1200d5c279643f28d6",
"branch": "master",
"ref": "refs/heads/master",
"message": "fix dockerfile\n",
"author": "adminuser",
"author_avatar": "https://secure.gravatar.com/avatar/0f656b0b09d16bafa95064e7e9bd83bc",
"author_email": "ziling.zhong@hand-china.com"
}
]