本文介绍了Teamcity REST API:获取工件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些问题:具有n个步骤的构建.最后一步是自定义c#通知程序,该通知程序发送有关构建状态的电子邮件.现在,我需要接收工件并将其附加到我的电子邮件中.问题在于,在最后一步,我们还没有压缩过的工件,这就是为什么我们需要自己找到并压缩它们的原因.在某些配置中,我没有任何属性"checkout directory".那么,如何获得root checkout文件夹和工件路径?

I have some problem:Have a build with n steps. Last step is a custom c# notifier, that sends emails about build state. Now I need to receive artifacts and attach them to my email. The problem is that at last step we don't have already zipped artifacts, that's why we need to find them ourselves and zip. In some configurations I don't have any property "checkout directory". So, how I can get root checkout folder and artifact path?

推荐答案

为了将文件附加到电子邮件,我认为您不需要使用REST API,而是使用内置参数来查找各种路径和位置.在没有完全理解您的构建管道的情况下,我只能猜测这就是您需要知道的.

In order to attach files to your email I don't think you need to be using the REST API, but inbuilt parameters to find out various paths and locations. Without fully understanding your build pipeline I can only have a guess that this is what you need to know.

TeamCity提供了许多参数,可帮助您选择各种路径

TeamCity offers a number of parameters that will help you with various paths

  • %teamcity.agent.work.dir%-这是代理的工作目录
  • %teamcity.build.checkoutDir%-这是代理的结帐目录
  • %system.teamcity.build.tempDir%-这是临时的构建目录
  • %teamcity.agent.work.dir% - This is the working directory of the agent
  • %teamcity.build.checkoutDir% - This is the checkout directory of the agent
  • %system.teamcity.build.tempDir% - This is the temporary build directory

将这些作为简单构建的一部分输出,我的是:

Outputting these as part of a simple build, mine are:

查看构建日志将帮助您弄清各个位的位置.同样,在不完全了解您的构建设置的情况下,我只能概括一下,但是在这里我们可以看到在checkout目录中正在生成.nupkg.

Looking in the build log will help you work out where various bits are going. Again without fully appreciating your build setup I can only generalise, but here we can see that a .nupkg is being produced in the checkout directory.

直到在构建配置中执行了最后一个构建步骤之后,TeamCity才会发布工件,除非您想使用##teamcity[publishArtifacts '<path>']强制执行此操作,但是除非您试图随后调用,否则我认为这不会对您有所帮助REST API来获取工件.

TeamCity won't publish artifacts until after the last build step has executed in a build configuration, unless you want to force this using ##teamcity[publishArtifacts '<path>'], but I don't think that will help you unless you are trying to then call the REST API to get to the artifacts.

希望这会有所帮助.

这篇关于Teamcity REST API:获取工件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 18:58