Daud
Daud

Reputation: 7887

how to make Jenkins create a tunnel before polling from SVN

I need to create a tunnel like the following before code can be checked out from SVN :

ssh -L 9898:some_server.com:9898 user@another_server.com

Now, I added pre-scm-buildstep plugin and wrote a script to open the tunnel before updating the repository as explained here, but it doesn't work with polling. It only works if I ask Jenkins to 'Build now'. In the setup where I have set it up to poll, its red saying that its unable to access the repository url, which can only happen if the tunnel was not created.

Is there any plugin such that I can execute a script before it polls, so that I can open the tunnel before it starts polling

Upvotes: 1

Views: 7069

Answers (1)

Tom Howard
Tom Howard

Reputation: 6687

Use ProxyCommand in your ssh config to have ssh automatically create the tunnel for you. e.g.,

Host another_server.com
    ProxyCommand ssh some_server.com exec nc %h %p

With the above in ~jenkins/.ssh/config (or whatever user jenkins runs as), when it tries to ssh to another_server.com it will actually ssh to some_server.com and run nc to forward the ssh connection to the another_server.com.

Upvotes: 2

Related Questions