简体   繁体   English

如何查找正在进行的TFS版本?

[英]How to find a TFS release in progress?

I need to fail a build on TFS 2018 if its pipeline is not fully complete. 如果TFS 2018的管道还没有完全完成,我需要在TFS 2018上构建失败。 Batching just the build is not enough; 仅批处理构建是不够的。 the linked release must be finished as well before another build can begin. 必须先完成链接的发行版,然后才能开始另一个构建。 My idea is to do this in a PowerShell script via the REST API. 我的想法是通过REST API在PowerShell脚本中执行此操作。

I see in the official documentation here that there's a property called TaskStatus . 我在这里的官方文档中看到有一个名为TaskStatus的属性。 It provides a value of inProgress , presumably for releases that are in progress. 它提供了inProgress的值,大概是针对正在进行的发行版。 This might do the trick, but there's no indication of how to actually use it. 这也许可以解决问题,但没有指示如何实际使用它。

Using the REST API, how can I get the TaskStatus of a given release? 使用REST API,如何获取给定版本的TaskStatus

The in process and some other values such as succeeded , canceled just stand for the status of a task in release pipeline. in process和某些其他值(例如succeededcanceled仅代表任务在发布管道中的状态。

You could simply use the Rest API to get a release 您只需使用Rest API即可发布

GET https://fabrikam.vsrm.visualstudio.com/MyFirstProject/_apis/release/releases/{releaseId}?api-version=4.1-preview.6

There should be a value called status: 应该有一个名为status的值:

"id": 18,
  "name": "Release-18",
  "status": "abandoned",
  "createdOn": "2017-06-16T01:36:20.397Z",
  "modifiedOn": "2017-06-16T01:36:21.07Z",
  "modifiedBy": {
    "id": "4adb1680-0eac-6149-b5ee-fc8b4f6ca227",
    "displayName": "Chuck Reinhart",
    "uniqueName": "fabfiber@outlook.com",
    "url": "https://app.vssps.visualstudio.com/A168224e4-29ff-4081-9954-c8780ce81117/_apis/Identities/4adb1680-0eac-6149-b5ee-fc8b4f6ca227",
    "imageUrl": "https://fabfiber-inc.visualstudio.com/_api/_common/identityImage?id=4adb1680-0eac-6149-b5ee-fc8b4f6ca227"
  },
  "createdBy": {
    "id": "4adb1680-0eac-6149-b5ee-fc8b4f6ca227",
    "displayName": "Chuck Reinhart",
    "uniqueName": "fabfiber@outlook.com",
    "url": "https://app.vssps.visualstudio.com/A168224e4-29ff-4081-9954-c8780ce81117/_apis/Identities/4adb1680-0eac-6149-b5ee-fc8b4f6ca227",
    "imageUrl": "https://fabfiber-inc.visualstudio.com/_api/_common/identityImage?id=4adb1680-0eac-6149-b5ee-fc8b4f6ca227"
  },
  "environments": [
    {
      "id": 69,
      "releaseId": 18,
      "name": "Dev",
      "status": "notStarted",
      "variables": {},
      "preDeployApprovals": [],
      "postDeployApprovals": [],
      "preApprovalsSnapshot": {
        "approvals": [
          {
            "rank": 1,
            "isAutomated": false,
            "isNotificationOn": false,
            "approver": {
              "id": "4adb1680-0eac-6149-b5ee-fc8b4f6ca227",
              "displayName": "Chuck Reinhart",
              "uniqueName": "fabfiber@outlook.com",
              "url": "https://app.vssps.visualstudio.com/A168224e4-29ff-4081-9954-c8780ce81117/_apis/Identities/4adb1680-0eac-6149-b5ee-fc8b4f6ca227",
              "imageUrl": "https://fabfiber-inc.visualstudio.com/_api/_common/identityImage?id=4adb1680-0eac-6149-b5ee-fc8b4f6ca227"
            },
            "id": 0
          }

You could fetch the value status in your return json file, and judge if the release succeed or failed. 您可以在返回的json文件中获取值状态,并判断发布是成功还是失败。 Finally according to this status to trigger another build or not. 最后根据此状态触发另一个构建或不构建。


Update 更新资料

A sample of the returned json with task's status info: 返回的json的示例,其中包含任务的状态信息:

  "deploymentJobs": [
                                {
                                    "job": {
                                        "id": 5,
                                        "timelineRecordId": "855ea6d6-9ed0-442d-b921-0c4add8bb068",
                                        "name": "Release",
                                        "dateStarted": "2018-07-04T08:53:05.9133333Z",
                                        "dateEnded": "2018-07-04T08:53:21.34Z",
                                        "startTime": "2018-07-04T08:53:05.9133333Z",
                                        "finishTime": "2018-07-04T08:53:21.34Z",
                                        "status": "succeeded",
                                        "rank": 1,
                                        "issues": [],
                                        "agentName": "DFA00"
                                    },
                                    "tasks": [
                                        {
                                            "id": 1,
                                            "timelineRecordId": "fa3bb635-eab4-4c1b-9cc0-fdccd7ced33f",
                                            "name": "Initialize Job",
                                            "dateStarted": "2018-07-04T08:53:06.5833333Z",
                                            "dateEnded": "2018-07-04T08:53:06.8033333Z",
                                            "startTime": "2018-07-04T08:53:06.5833333Z",
                                            "finishTime": "2018-07-04T08:53:06.8033333Z",
                                            "status": "succeeded",
                                            "rank": 1,
                                            "issues": [],
                                            "agentName": "DFA00",
                                            "logUrl": "http://xxxx:8080/tfs/DefaultCollection/7658559e-6e61-422a-952b-a5fce0b6ca1d/_apis/Release/releases/49/environments/49/tasks/1/logs?releaseDeployPhaseId=54"
                                        }, 

There should be timelinerecord , starttime , finishtime , status for a task deployment result in a single release. 在单个发布中,任务部署结果应该有timelinerecordstarttimefinishtimestatus

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM