How to turn log errors into build fails?

Hi,

We have an issue where occasionally we are seeing errors in our build logs but the build does not fail.

I would like to get a trigger that when specific errors appear in the logs we we set the build to fail and thus our developers are prompted to investigate.

I was trying to use if statements in our batch files but can't come up with the right statement.

An example condition is if make-ERROR is present in the log then set the build to fail.

 

 

1 answer

0 votes

Guess that's obvious, but I'd strongly recommend to identify why the build is not failing in your scenario, usually the build tool in question just requires an additional flag to return an error code to Bamboo (for example, you can return a non zero exit code from script tasks to let the build fail).

That being said, there are certainly scenarios where it might not possible or at least inconvenient to fix the build in this regard, here are two possible solutions:

1. Provided you can redirect the build tool output to a file, you might be able to leverage Iulius Hutuleac's Generic Test Results Parser for Bamboo, which offers Simple file parsing and test case handling for generic test result formats:

Just select the files, create a regular expression matching lines that should be treated as failed test cases and lines that should be treated as passed test cases.

2. Solution 1 is based on the Bamboo Test Collection and Reporting SPI, which allows you to "write your own Tasks that parse files or logs that contain test results and have the results display in Bamboo":

TestCollationService supports parsing custom test formats defined by either a custom TestReportCollector (file based) or TestReportProvider(non-file based) implementation.

As outlined, the TestCollationService supports files and log parsing, but solution 1 only supports the former right now. However, the app is available as open source on Bitbucket, so you can grab it for inspiration and create a dedicated app four your scenario (mind the GPL license though), or better yet submit a pull request that adds log parsing so that the community can benefit from this notable improvement :)

Suggest an answer

Log in or Join to answer
Community showcase
Renan Battaglin
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,069 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot