Bash build step with openvpn hangs build


I’m trying to connect to a VPN (due to IP whitelisting requirements of our test server). I couldn’t see a way to get the certificates required for the Bitrise VPN workflow step so instead I’ve modified the bash script for that step to accept the details I do have and used them in a “Script” workflow step.

However, when the step executes the Bitrise bot hangs/loses connection when it’s connecting to the VPN (I suspect it’s possibly successful in connecting to the VPN but that this action breaks the bot somehow?).

The Script step I’m using is:

sudo openvpn --client --dev tun --config test.ovpn --auth-user-pass password.txt --resolv-retry infinite --nobind --persist-key --persist-tun --comp-lzo --verb 3 > /dev/null 2>&1 &

sleep 5

if ifconfig -l | grep utun0 > /dev/null
echo “VPN connection succeeded”
echo “VPN connection failed!”
exit 1

If I run the openvpn command locally it successfully connects to the VPN.

Any ideas what I’m doing wrong?

It seems that openvpn client gets killed when script step finishes.
You need to send its process to background eg. by adding --daemon option.

1 Like

Thanks for the suggestion but it doesn’t seem to help. I suspect that establishing the VPN kills the SSH session somehow…?

Check If default route is not changed by received openvpn network configuration.

This is my script step content (working on Linux stack):

openvpn --daemon openvpn --status /run/openvpn.status 10 --config vpn.conf --writepid /run/
echo -e "nameserver <internal DNS ip>\n$(cat /etc/resolv.conf)" > /etc/resolv.conf

and configuration fragment:

dev tun

remote-cert-tls server
resolv-retry infinite
verb 1
script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

There is also openvpn step in the steplib.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.