简体   繁体   English

如何从TFS构建/发布中读取日志并相应地更改任务状态?

[英]How to read the logs from TFS Build/Release and change the task status accordingly?

I am using TFS(on premises 2015)automated build and release for one of my project. 我正在为我的一个项目使用TFS(在2015年前提)自动生成和发布。 In release definition, I have an ALM task and I can see the TFS release log returning "completed successfully: Y (or N) " in the log based on the task completion status in ALM and the ALM task always shows a success. 在发行版定义中,我有一个ALM任务,并且我可以看到TFS发行日志根据ALM中的任务完成状态在日志中返回“成功完成:Y(或N)”,并且ALM任务始终显示成功。 Is there any way that I can read the this "completed successfully: N" from the logs and fail the ALM release task itself as an indication of failure? 有什么方法可以从日志中读取此“成功完成:N”,并使ALM发布任务本身失败以指示失败?

Thanks in advance for any help! 在此先感谢您的帮助!

Well you're not giving much help here. 好吧,您在这里没有提供太多帮助。 With or having a better idea of what your script does... But you could do something like 了解或更好地了解脚本的功能...但是您可以执行以下操作

(At the end of your command) (在命令末尾)

Command -errorvariable fail
If ($fail -ne $null){
    $success = $fail
} Else {
    $success = $true
}

You could also pipe the error variable into the file at the next line if it's a txt log. 如果是txt日志,也可以将错误变量通过管道传递到文件的下一行。

Command -ev fail
$fail | out-file log.txt -append

Or 要么

Command -ev fail
If ($fail -ne $null) {
Write-output "the command failed at $variable" | out-file log.txt -append
}

$variable would be the variable used for your loop or whatever to identify the current task. $ variable是用于循环或用于标识当前任务的变量。

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

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