Timeout on long-running commands using the ssh-run pipe in Bitbucket Pipelines.

Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.

Summary

In Bitbucket Pipelines, when using the ssh-run pipe (https://bitbucket.org/atlassian/ssh-run/src/master/), long-running commands must lead to a timeout error.

Diagnosis

During the execution of long-running ssh commands, the server could go too long without receiving any response, leading to timeout errors.

Solution

The solution is to provide extra arguments on the pipe configuration. It will prevent the timeout error from happening.

Arguments:

  • ServerAliveInterval: This option sets a timeout interval in seconds, after which, if no data has been received from the server, ssh will send a message through the encrypted channel to request a response from the server.
  • ServerAliveCountMax: This option sets the number of server alive messages which may be sent without ssh receiving any messages back from the server. If this threshold is reached while server-alive messages are being sent, ssh will disconnect from the server, terminating the session.

An example application of the suggested arguments:

Pipe: ssh-run
- pipe: atlassian/ssh-run:0.4.1
  variables:
    SSH_USER: '<string>'
    SERVER: '<string>'
    COMMAND: '<string>'
    MODE: "command"
    EXTRA_ARGS: "-v -o ServerAliveInterval=1200 ServerAliveCountMax=3"

Last modified on Sep 27, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.