Michael W
Michael W

Reputation: 3555

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

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

Upvotes: 5

Views: 5326

Answers (1)

Peterino
Peterino

Reputation: 16747

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.)

Upvotes: 6

Related Questions