TFS/VSTS vNext 构建和发布日志位置
TFS/VSTS vNext Build and Release Logs Location
构建和发布日志是否保存在 Build Agent 机器本地?我知道我可以为每个构建和发布手动单击 "Download all logs as zip" link,但是如果我想自动将这些日志发送给其他人(或批量发送),是否有另一种方法可以找到他们(在 Build Agent 机器上或数据库中的某个地方)?
谢谢!
对于 TFS 和 VSTS,build/release 日志位于 TFS/VSTS 服务器 (与使用的代理无关)。
在 build/release retention 中,您可以设置策略以保留 builds/releases。它默认保留最近 30 天的构建和发布。
除了点击"Download all logs as zip"按钮获取build/release条日志外,您还可以通过REST API获取build/release条日志。比如下面的例子:
GET https://account.visualstudio.com/DefaultCollection/Git2/_apis/build/builds/2373/timeline?api-version=2.0
并且可以在响应中获取每个构建步骤的日志,例如:
{
"records": [
{
"id": "d2c6b274-40fe-4727-85b6-eb92fb4f6009",
"parentId": "ff7265dc-abe3-5e6a-6194-76bb88f00044",
"type": "Task",
"name": "Initialize Job",
"startTime": "2018-01-15T05:30:25.6Z",
"finishTime": "2018-01-15T05:30:26.0233333Z",
"currentOperation": null,
"percentComplete": null,
"state": "completed",
"result": "succeeded",
"resultCode": null,
"changeId": 8,
"lastModified": "0001-01-01T00:00:00",
"workerName": "V-myPC",
"order": 2,
"details": null,
"errorCount": 0,
"warningCount": 0,
"url": null,
"log": {
"id": 2,
"type": "Container",
"url": "https://account.visualstudio.com/DefaultCollection/f7855e29-6f8d-429d-8c9b-41fd4d7e70a4/_apis/build/builds/2373/logs/2"
},
"task": null
},
...
],
"lastChangedBy": "00000002-0000-8888-8000-000000000000",
"lastChangedOn": "2018-01-15T05:30:40.947Z",
"id": "4b4280d4-5358-4238-ab95-d44475c92bc9",
"changeId": 19,
"url": "https://account.visualstudio.com/DefaultCollection/f7855e29-6f8d-429d-8c9b-41fd4d7e70a4/_apis/build/builds/2373/Timeline/4b4280d4-5358-4238-ab95-d44475c92bc9"
}
如上响应,您可以通过url https://account.visualstudio.com/DefaultCollection/f7855e29-6f8d-429d-8c9b-41fd4d7e70a4/_apis/build/builds/2373/logs/2.
找到Initialized Job步骤
构建和发布日志是否保存在 Build Agent 机器本地?我知道我可以为每个构建和发布手动单击 "Download all logs as zip" link,但是如果我想自动将这些日志发送给其他人(或批量发送),是否有另一种方法可以找到他们(在 Build Agent 机器上或数据库中的某个地方)?
谢谢!
对于 TFS 和 VSTS,build/release 日志位于 TFS/VSTS 服务器 (与使用的代理无关)。
在 build/release retention 中,您可以设置策略以保留 builds/releases。它默认保留最近 30 天的构建和发布。
除了点击"Download all logs as zip"按钮获取build/release条日志外,您还可以通过REST API获取build/release条日志。比如下面的例子:
GET https://account.visualstudio.com/DefaultCollection/Git2/_apis/build/builds/2373/timeline?api-version=2.0
并且可以在响应中获取每个构建步骤的日志,例如:
{
"records": [
{
"id": "d2c6b274-40fe-4727-85b6-eb92fb4f6009",
"parentId": "ff7265dc-abe3-5e6a-6194-76bb88f00044",
"type": "Task",
"name": "Initialize Job",
"startTime": "2018-01-15T05:30:25.6Z",
"finishTime": "2018-01-15T05:30:26.0233333Z",
"currentOperation": null,
"percentComplete": null,
"state": "completed",
"result": "succeeded",
"resultCode": null,
"changeId": 8,
"lastModified": "0001-01-01T00:00:00",
"workerName": "V-myPC",
"order": 2,
"details": null,
"errorCount": 0,
"warningCount": 0,
"url": null,
"log": {
"id": 2,
"type": "Container",
"url": "https://account.visualstudio.com/DefaultCollection/f7855e29-6f8d-429d-8c9b-41fd4d7e70a4/_apis/build/builds/2373/logs/2"
},
"task": null
},
...
],
"lastChangedBy": "00000002-0000-8888-8000-000000000000",
"lastChangedOn": "2018-01-15T05:30:40.947Z",
"id": "4b4280d4-5358-4238-ab95-d44475c92bc9",
"changeId": 19,
"url": "https://account.visualstudio.com/DefaultCollection/f7855e29-6f8d-429d-8c9b-41fd4d7e70a4/_apis/build/builds/2373/Timeline/4b4280d4-5358-4238-ab95-d44475c92bc9"
}
如上响应,您可以通过url https://account.visualstudio.com/DefaultCollection/f7855e29-6f8d-429d-8c9b-41fd4d7e70a4/_apis/build/builds/2373/logs/2.
找到Initialized Job步骤