I have two jenkins instances. I want job at 1st instance to invoke job at 2nd instance, wait until it ends and perform some actions (using artifacts produced by job @ 2nd)

I've come up with this solution - using Jenkins CLI commands via SSH

ssh -p 2222 second-jenkins build second-job -s -v <further options>

But this session disconnects after 10minutes with message:

Received disconnect from 2: User idle has timed out after 600000ms.

I found ssh client option named ServerAliveInterval

ssh -o ServerAliveInterval=30 -p 2222 second-jenkins build second-job -s -v <...>

Documentation for this option says


Sets a timeout interval in seconds after which if no data has been received from the server, ssh(1) will send a message through the encrypted channel to request a response from the server. The default is 0, indicating that these messages will not be sent to the server. This option applies to protocol version 2 only.

This works but only when server is quiet by at least 30 seconds within every 10 minutes. Of course I can use 1 second instead 30, but it wont work for jobs with continous console output (eg. maven builds).

Is there solution which keep connection alive even for hevy console output jobs?


Add this to Jenkins startup to disable the SSHD timeout:


See also https://medium.com/@alaoui.rda/jenkins-cli-ssh-timeout-38386c943c22

| improve this answer | |

You should take a look at screen or tmux. Install one of them on remote host and launch your command inside that session. ssh has -t option to allocate tty, so you should do something like this for screen:

$ ssh -t user@host screen 'your_command'

| improve this answer | |
  • this is not possible since i'm connecting to jenkins built-in ssh server which provides only predefined set of commands see here – tworec Aug 12 '16 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.