Created
April 16, 2018 15:00
-
-
Save firemanxbr/bf2429a5fab065802e8bfd4380fe2bfa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node('maven') { | |
def productName = "rhproduct" | |
def url = "https://jenkins-rhproduct.192.168.42.242.nip.io" | |
def sa = "system:serviceaccount:${productName}:jenkins-admin".replaceAll(":", "_") | |
echo "${sa}" | |
sh 'wget https://gist.githubusercontent.com/scoheb/c960a534b592552d96265f03af52f4bf/raw/f74c5799e7c7a727ee1d42b2cfd06811ef283ac4/gistfile1.txt -O get-api-token.groovy' | |
sh 'curl -k --data-urlencode "script=$(< ./get-api-token.groovy)" -H "Authorization: Bearer `oc serviceaccounts get-token jenkins -n ' + productName + '`" ' + url + '/scriptText' | |
String apiToken = sh( | |
script: 'curl -k --data-urlencode "script=$(< ./get-api-token.groovy)" -H "Authorization: Bearer `oc serviceaccounts get-token jenkins -n ' + productName + '`" ' + url + '/scriptText | cut -c8-', | |
returnStdout: true | |
).trim() | |
echo apiToken | |
sh 'curl -k -H "Authorization: Bearer `oc serviceaccounts get-token jenkins -n ' + productName + '`" ' + url + '/job/test/build' | |
//sh "wget --no-check-certificate ${url}/jnlpJars/jenkins-cli.jar -O /tmp/jenkins-cli.jar" | |
//sh "java -jar /tmp/jenkins-cli.jar -auth ${sa}:${apiToken} -noCertificateCheck -s ${url} build test -w" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment