corrects syntax
This commit is contained in:
parent
c0018f3e49
commit
93c0e5bb4c
@ -42,84 +42,84 @@ pipeline {
|
|||||||
stage ('Prepare Values') {
|
stage ('Prepare Values') {
|
||||||
steps {
|
steps {
|
||||||
container ('alpine') {
|
container ('alpine') {
|
||||||
retry(3) {
|
script {
|
||||||
try {
|
retry(3) {
|
||||||
// list of urls that return different nordVPN servers
|
try {
|
||||||
def nordURLs = [
|
// list of urls that return different nordVPN servers
|
||||||
// canada
|
def nordURLs = [
|
||||||
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:38,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
// canada
|
||||||
// costa-rica
|
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:38,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
||||||
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:52,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
// costa-rica
|
||||||
// denmark
|
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:52,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
||||||
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:58,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
// denmark
|
||||||
// france
|
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:58,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
||||||
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:74,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
// france
|
||||||
// gremany
|
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:74,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
||||||
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:81,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
// gremany
|
||||||
// japan
|
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:81,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
||||||
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:108,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
// japan
|
||||||
// sweden
|
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:108,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
||||||
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:208,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
// sweden
|
||||||
// switzerland
|
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:208,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
||||||
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:209,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
// switzerland
|
||||||
// netherlands
|
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:209,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
||||||
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:153,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
// netherlands
|
||||||
// united kingdom
|
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:153,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
||||||
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:38,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
// united kingdom
|
||||||
]
|
"https://nordvpn.com/wp-admin/admin-ajax.php?action=servers_recommendations&filters=\\{%22country_id%22:38,%22servers_groups%22:\\[15\\],%22servers_technologies%22:\\[5\\]\\}",
|
||||||
// randomly select one from the list
|
]
|
||||||
nordURL = nordURLs[Math.abs(new Random().nextInt() % [8])]
|
// randomly select one from the list
|
||||||
|
nordURL = nordURLs[Math.abs(new Random().nextInt() % [8])]
|
||||||
|
|
||||||
// install required components
|
// install required components
|
||||||
script {
|
script {
|
||||||
sh """
|
sh """
|
||||||
if [ ! -f "/usr/bin/curl" ] || [ ! -x "/usr/bin/curl" ]; then
|
if [ ! -f "/usr/bin/curl" ] || [ ! -x "/usr/bin/curl" ]; then
|
||||||
apk add --no-cache curl
|
apk add --no-cache curl
|
||||||
fi
|
fi
|
||||||
if [ ! -f "/usr/bin/jq" ] || [ ! -x "/usr/bin/jq" ]; then
|
if [ ! -f "/usr/bin/jq" ] || [ ! -x "/usr/bin/jq" ]; then
|
||||||
apk add --no-cache jq
|
apk add --no-cache jq
|
||||||
fi
|
fi
|
||||||
if [ ! -f "/bin/sed" ] || [ ! -x "/bin/sed" ]; then
|
if [ ! -f "/bin/sed" ] || [ ! -x "/bin/sed" ]; then
|
||||||
apk add --no-cache sed
|
apk add --no-cache sed
|
||||||
fi
|
fi
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
// get OpenVPN Configuration from NordVPN
|
// get OpenVPN Configuration from NordVPN
|
||||||
openVPNConfig = sh(
|
openVPNConfig = sh(
|
||||||
returnStdout: true,
|
returnStdout: true,
|
||||||
script: """# Get OpenVPN Config
|
script: """# Get OpenVPN Config
|
||||||
curl \
|
curl \
|
||||||
--silent \
|
--silent \
|
||||||
--location \
|
--location \
|
||||||
--fail \
|
--fail \
|
||||||
"https://downloads.nordcdn.com/configs/files/ovpn_tcp/servers/\$(
|
"https://downloads.nordcdn.com/configs/files/ovpn_tcp/servers/\$(
|
||||||
curl \
|
curl \
|
||||||
--silent \
|
--silent \
|
||||||
--location \
|
--location \
|
||||||
--fail \
|
--fail \
|
||||||
'""" + nordURL + """' \
|
'""" + nordURL + """' \
|
||||||
| jq \
|
| jq \
|
||||||
--raw-output \
|
--raw-output \
|
||||||
'[.[] | select(.technologies[] | .identifier == "openvpn_tcp")][0] | .hostname' \
|
'[.[] | select(.technologies[] | .identifier == "openvpn_tcp")][0] | .hostname' \
|
||||||
).tcp.ovpn" \
|
).tcp.ovpn" \
|
||||||
| sed \
|
| sed \
|
||||||
--regexp-extended \
|
--regexp-extended \
|
||||||
--expression='s/auth-user-pass/auth-user-pass \\/etc\\/openvpn\\/client\\/openvpn-credentials.txt/' \
|
--expression='s/auth-user-pass/auth-user-pass \\/etc\\/openvpn\\/client\\/openvpn-credentials.txt/' \
|
||||||
| base64 -w 0
|
| base64 -w 0
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
if (openVPNConfig.length() == 0 || openVPNConfig == "") {
|
if (openVPNConfig.length() == 0 || openVPNConfig == "") {
|
||||||
printf("Bad nordURL: %s", nordURL)
|
printf("Bad nordURL: %s", nordURL)
|
||||||
throw e
|
throw e
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Create K8S Secret
|
// Create K8S Secret
|
||||||
script {
|
|
||||||
withCredentials(
|
withCredentials(
|
||||||
[
|
[
|
||||||
string(
|
string(
|
||||||
|
Reference in New Issue
Block a user