corrects syntax

This commit is contained in:
Hyatt 2023-10-22 09:57:38 -05:00
parent 67b3595479
commit c0018f3e49
Signed by: nhyatt
GPG Key ID: C50D0BBB5BC40BEA

@ -39,7 +39,7 @@ pipeline {
} }
} }
stage ('Prepare Vales') { stage ('Prepare Values') {
steps { steps {
container ('alpine') { container ('alpine') {
retry(3) { retry(3) {
@ -85,52 +85,50 @@ pipeline {
""" """
} }
// get OpenVPN Configuration from NordVPN // get OpenVPN Configuration from NordVPN
retry(3) { openVPNConfig = sh(
try { returnStdout: true,
openVPNConfig = sh( script: """# Get OpenVPN Config
returnStdout: true, curl \
script: """# Get OpenVPN Config --silent \
curl \ --location \
--silent \ --fail \
--location \ "https://downloads.nordcdn.com/configs/files/ovpn_tcp/servers/\$(
--fail \ curl \
"https://downloads.nordcdn.com/configs/files/ovpn_tcp/servers/\$( --silent \
curl \ --location \
--silent \ --fail \
--location \ '""" + nordURL + """' \
--fail \ | jq \
'""" + nordURL + """' \ --raw-output \
| jq \ '[.[] | select(.technologies[] | .identifier == "openvpn_tcp")][0] | .hostname' \
--raw-output \ ).tcp.ovpn" \
'[.[] | select(.technologies[] | .identifier == "openvpn_tcp")][0] | .hostname' \ | sed \
).tcp.ovpn" \ --regexp-extended \
| sed \ --expression='s/auth-user-pass/auth-user-pass \\/etc\\/openvpn\\/client\\/openvpn-credentials.txt/' \
--regexp-extended \ | base64 -w 0
--expression='s/auth-user-pass/auth-user-pass \\/etc\\/openvpn\\/client\\/openvpn-credentials.txt/' \ """
| base64 -w 0 )
""" } catch(e) {
) if (openVPNConfig.length() == 0 || openVPNConfig == "") {
} catch(e) { printf("Bad nordURL: %s", nordURL)
if (openVPNConfig.length() == 0 || openVPNConfig == "") { throw e
printf("Bad nordURL: %s", nordURL)
throw e
}
}
}
} }
} }
}
}
withCredentials( // Create K8S Secret
[ script {
string( withCredentials(
credentialsId: nordCreds, [
variable: "NORD_CREDS", string(
) credentialsId: nordCreds,
] variable: "NORD_CREDS",
) { )
]
k8sSecret = """apiVersion: v1 ) {
k8sSecret = """apiVersion: v1
kind: Secret kind: Secret
metadata: metadata:
name: """ + kubeSecret + """ name: """ + kubeSecret + """
@ -139,13 +137,12 @@ data:
openvpn-credentials.txt: """ + NORD_CREDS + """ openvpn-credentials.txt: """ + NORD_CREDS + """
nordvpn.com.tcp.ovpn: """ + openVPNConfig + """ nordvpn.com.tcp.ovpn: """ + openVPNConfig + """
""" """
}
} }
} }
} }
} }
stage ('Create Secret') { stage ('Update Secret') {
steps { steps {
container ('alpine') { container ('alpine') {
script { script {