2

So here is my issue. I have a prebuild script in TFS2013 that runs JSHint through a gulp command. I want to make the script error if there are any warnings, and I have that working, but the error in the TFS detail is a lot more than the one line I was expecting.

In my powershell script I doing this:

 Write-Error "$count files have JSHint warnings"

But here is the error detail in TFS: TFS Error detail

Is there any way to make powershell error in a way that will make the build partially succeed/fail with an error detail that does not include all of this extra stuff in it? (You can see that the 2nd error is actually the error from the powershell script.)

LRFalk01
  • 961
  • 8
  • 17
  • Don't use `Write-Error` or tell it to do something other than exit with `-ErrorAction`? – Etan Reisner Jun 26 '15 at 22:27
  • -ErrorAction Continue still adds all of that extra data into the error. What other option do I have from Write-Error or throw [System.Exception]. Throw also puts in a bunch of extra data that is not just the error message that I want to show. – LRFalk01 Jun 26 '15 at 22:34
  • Just write the output and exit? – Etan Reisner Jun 26 '15 at 22:36
  • This will not make the build partially succeed which is what I am after. I have this JSHint check running on every check in so that the team is made aware of someone checking in potentially bad JavaScript. – LRFalk01 Jun 26 '15 at 22:39
  • What about `-ErrorAction SilentlyContinue`? – Etan Reisner Jun 26 '15 at 22:46
  • This also does not cause the build to partially succeed. TFS sees no errors in the pre-build script and assumes all is gravy. – LRFalk01 Jun 26 '15 at 23:02
  • 1
    Does http://stackoverflow.com/q/4998173/258523 help here? – Etan Reisner Jun 26 '15 at 23:06

1 Answers1

2

I figured it out!

$Host.UI.WriteErrorLine("$count files have JSHint warnings")

This writes a single line to the TFS build details error list without any of the extra detail that throw or Write-Error inject.

LRFalk01
  • 961
  • 8
  • 17