Last active
February 28, 2018 17:42
-
-
Save InTheCloudDan/84f4bca4068ed7b04692c5e9b9b63921 to your computer and use it in GitHub Desktop.
This file contains 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
@NonCPS | |
def call(String repository, String credentials) { | |
//withCredentials([usernamePassword(credentialsId: credentials, | |
// usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { | |
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: credentials.toString(), passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME']]) { | |
println env.USERNAME | |
println env.PASSWORD | |
sh 'echo $USERNAME and $PASSWORD' | |
def authString = "${env.USERNAME}:${env.PASSWORD}".encodeBase64().toString(); | |
URLConnection conn = new URL("https://api.${githubUrl}.com/repos/${repository}/releases/latest").openConnection(); | |
conn.setRequestProperty("Authorization", "Basic ${authString}") | |
def releases = new groovy.json.JsonSlurper().parse(new BufferedReader(new InputStreamReader(conn.getInputStream()))); | |
releases.each { | |
println it.name | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment