简体   繁体   English

将值从Powershell传递到TFS Build Workflow

[英]Pass a value from powershell to TFS Build Workflow

I have a build which kicks off a PowerShell script. 我有一个启动PowerShell脚本的构建。 What it does is gather code coverage metrics and then stores that info in a database. 它的作用是收集代码覆盖率指标,然后将该信息存储在数据库中。 I'd like to pass a value out of that script and back into the build workflow so I can pass or fail the build based on that value. 我想从该脚本中传递一个值,然后将其传递回构建工作流,以便我可以基于该值传递或失败构建。

Any ideas on how I could accomplish that? 关于如何实现目标的任何想法?

Easiest way is to have PowerShell throw an exception. 最简单的方法是让PowerShell引发异常。 That will also cause Powershell to return a non-0 exit code. 这也将导致Powershell返回非0的退出代码。 In your InvokeProcess you can either handle the Error stream or have the Result parameter assigned to a variable on your build workflow, then follow that with an if block to pass or fail the build. InvokeProcess您可以处理Error流,或者将Result参数分配给构建工作流中的变量,然后在其后加上if块以通过或失败构建。

Or you can return the coverage outcome using the exit function, it will be assigned to the Result property of the InvokeProcess Activity. 或者,您可以使用exit函数返回coverage结果,该Result将分配给InvokeProcess活动的Result属性。

exit 12345;

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

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