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

474 Views Asked by At

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!

1

There are 1 best solutions below

1
On

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.