Skip to content

Instantly share code, notes, and snippets.

@kevincloud
Created May 19, 2020 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kevincloud/25e83efb3b128a1dfb5f9164820c0b49 to your computer and use it in GitHub Desktop.
Save kevincloud/25e83efb3b128a1dfb5f9164820c0b49 to your computer and use it in GitHub Desktop.
def getPlanStatus(runid) {
def result = ""
def response = httpRequest(
customHeaders: [[ name: "Authorization", value: "Bearer " + env.BEARER_TOKEN ]],
url: "https://app.terraform.io/api/v2/runs/${runid}"
)
def data = new JsonSlurper().parseText(response.content)
switch (data.data.attributes.status) {
case 'pending':
result = "noop"
break
...
case 'policy_override':
result = "approve_policy:" + data.data.relationships["policy-checks"].data[0].id
break
...
default:
result = "running"
break
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment