HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Jenkins job using VPN?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
jenkinsvpnjobusing

Problem

Is there a way to connect to a VPN for the duration of a Jenkins job? (freestyle or pipeline, I can work with either).

I scoured the plugin list figuring someone might have developed something, but the only page found was this OpenConnect page with no actual code developed, so that seems to be out.

We're running Jenkins on Ubuntu AWS boxes, if that changes anything. I'd prefer the ability to connect and disconnect in a single job, rather than making everything run on VPN.

Solution

If you want to VPN for a jenkins task you would want to use the OpenConnect plugin as you mentioned.

Here are the steps to do that:

On linux (debian based)

sudo apt-get install openconnect


Add the following lines to the bottom of /etc/sudoers (ubuntu configuration)

jenkins ALL=NOPASSWD:/usr/sbin/openconnect*
jenkins ALL=NOPASSWD:/bin/kill*


The you will get an option in the Jenkins run task called:

Connect to Cisco AnyConnect VPN


Can also be found here:
https://stackoverflow.com/questions/35151072/deploy-with-jenkins-to-vpn/43357784#43357784

Code Snippets

sudo apt-get install openconnect
jenkins ALL=NOPASSWD:/usr/sbin/openconnect*
jenkins ALL=NOPASSWD:/bin/kill*
Connect to Cisco AnyConnect VPN

Context

StackExchange DevOps Q#1818, answer score: 3

Revisions (0)

No revisions yet.