Nux
Nux

Reputation: 10032

How to mark the build as failure after SSH timeout in Jenkins?

Currently if I run a pre-build step (which makes a backup...) over SSH and when it times-out it just marks the build as unstable but it continues to build - very bad in my case!

This is what I see in the log:

ERROR: Exception when publishing, exception message [Exec timed out or was interrupted after 120 022 ms]

Build step 'Send files or execute commands over SSH' changed build result to UNSTABLE

So the question is - how to stop build on timeout?

Upvotes: 2

Views: 3404

Answers (2)

Nux
Nux

Reputation: 10032

After some testing I decided to install the Text-finder Plugin. Then after SSH is executed I added a Conditional step with Text Finder setup as following:

Text Finder setup for SSH failure

My current RegExp is actually different now:

(\[ERROR\]|ERROR: Exception when publishing)

This is because I noticed that doing exit 1 in SSH shell doesn't make Jenkins fail. So I also catch "[ERROR]" which I echo out on error. Note that commands run over SSH are shown in the log, so if you do something similar, then you're echo code would have to look similar to this: echo "[""ERROR]".

Upvotes: 1

Amey
Amey

Reputation: 8548

Maybe this plugin would be helpful for you

Build-timeout Plugin

Upvotes: 0

Related Questions