简体   繁体   中英

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. 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. 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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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