2

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!

Fredrik Widerberg
  • 3,068
  • 10
  • 30
  • 42
Annu
  • 23
  • 4

1 Answers1

0

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.

Robert Cotterman
  • 2,213
  • 2
  • 10
  • 19
  • Is there any way I can get the logs from the TFS release definition other than "Download all logs as zip" option and later parse the log to find the "Completed Successfully:N" and fail that TFS task within Release definition? – Annu Aug 14 '18 at 08:07