Skip to content

Instantly share code, notes, and snippets.

@onyxhat
Created September 13, 2018 16:58
Show Gist options
  • Save onyxhat/d32a47dec8effe3aae44db9f5e3100d6 to your computer and use it in GitHub Desktop.
Save onyxhat/d32a47dec8effe3aae44db9f5e3100d6 to your computer and use it in GitHub Desktop.
[string]$UserName = "myJenkinsUser"
[string]$Jenkins_Token = "myJenkinsUserApiKey"
[uri]$Build_URL = "http://jenkins.local/job/myAwesomeApp/latest/"
$Headers = @{
"Authorization" = "Basic " + [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${UserName}:${Jenkins_Token}"))
}
$jobObj = Invoke-RestMethod -Headers $Headers -Uri "${Build_URL}/api/json"
$jobObj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment