2

We've got a Swift iOS project building on Jenkins, using the Xcode plugin.

In the project we're using SwiftLint to validate our code syntax, which produces Xcode warnings or errors if code syntax is incorrect (e.g. if you write something like let num :CGFloat =1).

SwiftLint runs a script after the project has built. So note these are NOT compiler warnings, but Xcode warnings that it pops up.

Is there a way to fail the Jenkins build if there are any Xcode warnings?

Jon Cox
  • 10,622
  • 22
  • 78
  • 123
  • Jenkins will probably only care about the exit code of `xcodebuild`, so the question should be "is there a way to make warnings fatal in xcodebuild`. – trojanfoe May 11 '16 at 09:38

2 Answers2

3

Taking the suggestion from OltzU to use the Warnings Plugin, I installed it on Jenkins.

I then added the Post-build action: Scan for compiler warnings...

set the Parser to Clang (LLVM based)...

clicked on the Advanced... button...

scrolled down a little bit to the Status thresholds (Totals) section...

set the number off acceptable warnings and errors to 0 for All priorities: enter image description here

and saved and rebuilt.

Voila! It now fails builds even with just SwiftLint warnings - thanks to SwiftLint spitting out logs of warnings to the console in the same format as xcodebuild. Happy days

Community
  • 1
  • 1
Jon Cox
  • 10,622
  • 22
  • 78
  • 123
1

You could use Warnings plugin with custom parser to identify these warnings and set it to fail the build if warnings are found.

Custom parsers can be configured in the Jenkins System configuration after installing the plugin. They require writing a regular expression to catch the lines you are interested in, and groovy scripting for returning a new Warning object for each line matched.

OltzU
  • 666
  • 7
  • 4
  • Thanks for the possible solution @OltzU. It may require more time than fixing this is worth, but if I do it I'll let you know the results :) – Jon Cox May 12 '16 at 08:39