Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I fail a build based on the outcome of a SSH Task?

Tags:

ssh

bamboo

I was wondering if I could use bamboo's SSH task to run a script (this kicks off a small java message injector).

Then grep the logs for ERRORS. If any ERROR is present I would like to fail the build.

Something like this:

enter image description here

like image 918
Michael W Avatar asked Aug 27 '14 15:08

Michael W


1 Answers

Is this a Bash question or is it really about Bamboo? Here is the Bash problem answer:

If you run

[[ ! $(grep ERROR /a/directory/log/*) ]]

the script will exit with an error if it finds the word "ERROR" anywhere in the files.

Bamboo should detect the task execution as failed.

(Note that if Bash is not the default shell on your target system you may need a #!/bin/bash on top of the script file.)

like image 167
Peterino Avatar answered Sep 17 '22 13:09

Peterino