1

Using bamboo v5.7 with msbuild v12, how do I fail a build if there are any static code analysis warnings? We do have our projects all set to treat all warnings as errors so the project itself doesn't build, but bamboo is not detecting this and continues on.

This seems basic, what might I be doing wrong?

BrettRobi
  • 3,793
  • 7
  • 40
  • 64

2 Answers2

1

The simple answer is you are doing nothing wrong, nor are you missing anything.

While it seems like basic functionality, Bamboo's MSBuild task currently doesn't support reading, reporting or failing the build on Warnings or Errors. The task only fails because MSBuild (or XBuild if you are using Mono) returns with an error code when a compiler error occurs.

Also, MSBuild doesn't actually support failing on all warnings either, as you can see here.

You have a couple options.

  • You can use one of the options in the referenced post
  • You could roll your own MSBuild log parser plugin using Atlassian's Plugin SDK.
  • You could make a simple script that is executed after the build, reads the logs and returns a non-zero integer if there were compiler warnings.
  • You can vote for the issue in the Atlassian Jira and also for the related issue for parsing build details.

Whatever your solution, I hope you share it with the many of us that have run into the same problem. It seems to be something quite common, so I was surprised there wasn't an issue already open for this in Atlassian's Jira instance

Community
  • 1
  • 1
chaosaffe
  • 848
  • 9
  • 22
0

For VS 2008 and later, a new project setting was added for this. See this link.

Mark Woodard
  • 51
  • 1
  • 8
  • Whilst this may theoretically answer the question, [it would be preferable](//meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – BrokenBinary Dec 21 '16 at 20:18
  • The link is under the word 'this', but I'll spell it out: https://blogs.msdn.microsoft.com/codeanalysis/2007/08/08/codeanalysistreatwarningsaserrors-msbuild-property/. – Mark Woodard Jan 23 '17 at 21:01
  • Essentially, it just says to add true to the first PropertyGroup in your project file. – Mark Woodard Jan 23 '17 at 21:02