KISS πŸ‡ΊπŸ‡¦

Stop the war!

Stop the war in Ukraine! Fuck putin!

More information is at: https://war.ukraine.ua/.

There is a fund to support the Ukrainian Army: https://savelife.in.ua/en/donate/, and there is a special bank account that accepts funds in multiple currencies: https://bank.gov.ua/en/about/support-the-armed-forces. I donated to them. Please donate if you can!

Killer putin

Killer putin. Source: politico.eu.

Arrested putin

"It hasn't happened yet, but it will happen sooner or later. Beautiful photo, isn't it?" Source: twitter.

Jenkins: custom Clang warnings parser

| comments

The Warnings Plugin already provides a Clang (LLVM based) warnings parser, but in my case I needed to set high priority to specific class of warnings. It’s a small post on how to create a custom parser for Clang warnings.

I assume the aforementioned plugin is already installed on your Jenkins. Go to Manage Jenkins > Configure System. Find the Compiler Warnings section somewhere towards the bottom, press Add to add a new parser. Here are the parameters:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Name: Clang-LLVM
Link name: Clang Compiler Warnings
Trend report name: Clang Warning Trend
Regular Expression: ^(.+?):(\d+):(?:\d+:)?(?:\{\d:-\}+)?(?:.*) (warning|error): (.*)$
Mapping Script:
    import hudson.plugins.warnings.parser.Warning
    import hudson.plugins.analysis.util.model.Priority

    String fileName = matcher.group(1)
    int lineNumber = Integer.parseInt(matcher.group(2))
    String category = matcher.group(3)
    String message = matcher.group(4)
    Priority priority = Priority.NORMAL

    if (message.contains('deprecated')) category = 'deprecation';
    if (message.contains('not implemented')) priority = Priority.HIGH;

    return new Warning(fileName, lineNumber, "Clang-LLVM", category, message, priority);
Example Log Message:
    /Users/Shared/Jenkins/Home/jobs/project/workspace/src/AwesomeClass.m:25:17: warning: method 'theBestPlaceInTheWorld:' in protocol 'PlaceSelector' not implemented [-Wprotocol]

That’s it! You can customize it to set different categories and priorities in the lines between parsing a line and returning a new Warning object. In this case, all messages containing deprecated will have the deprecation category, and all messages mentioning not implemented will have a high priority.

Important note: the plugin de-duplicates the warnings. Since the parser is one line only (although Clang’s warnings are multiline), you can bump into a weird issue when the plugin displays fewer warnings than the Xcode generates. It happens if there is a warning in a header included from different files, in this case the actual warning in the header will be exactly the same, and the difference is in the context (above and/or below lines, which are not parsed). The plugin apparently supports multiline regular expressions, but they are quite slow, and I haven’t tried that approach. (See also: https://issues.jenkins-ci.org/browse/JENKINS-8399 and https://issues.jenkins-ci.org/browse/JENKINS-17132).

Comments