Start vNext build from Powershell and get artifacts

前端 未结 2 1698
独厮守ぢ
独厮守ぢ 2020-12-30 07:32

In order to automate our deployments, I would like to rebuild an application, based on a given ChangeSetId. Once this build has completed, I want to get the artifacts

2条回答
  •  半阙折子戏
    2020-12-30 08:18

    TFS 2015 comes with the new REST API, and it includes the method to get the artifacts of the specific build. I would approach your challenge in the following way:

    • Add a "PowerShell script" build step after your "Publish artifacts" step
    • In that PowerShell script:
      • Get the ID of the current build. TFS exposes a number of predefined variables, and build ID is there. All those variables end up as environment variable, and this post can help you read the appropriate one from your PowerShell script
      • Next, make a web request to get build artifacts. As you can see from the API description, you'll have to provide just the build ID
      • Then, parse the JSON response - the downloadUrl property contains the link to download all the artifacts of the build zipped as a single archive
      • Finally, extract the archive and pick up those artifacts you need. Perhaps, you'd like to deploy it to your testing environment in this step as well

    Hope this helps.

提交回复
热议问题