1

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 192.168.147.102: 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

ServerAliveInterval

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?

tworec
  • 163
  • 2
  • 8

2 Answers2

1

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'

cuongnv23
  • 230
  • 3
  • 9
  • this is not possible since i'm connecting to jenkins built-in ssh server which provides only predefined set of commands [see here](https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+SSH) – tworec Aug 12 '16 at 13:17
1

Add this to Jenkins startup to disable the SSHD timeout:

-Dorg.jenkinsci.main.modules.sshd.SSHD.idle-timeout=0

See also https://blog.redaalaoui.me/blog/jenkins-cli-ssh-timeout/