Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,295,423
Community Members
 
Community Events
165
Community Groups

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 Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo Data Center on Kubernetes

Hi, If you are running self-managed environments and looking to adopt modern infrastructure, Bamboo Data Center can now be deployed in a Kubernetes cluster. By leveraging Kubernetes, you can easily...

942 views 3 8
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you