Skip to content

Instantly share code, notes, and snippets.

@OldCrowEW
Forked from kevincloud/tfsentinel-3.groovy
Created July 20, 2020 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OldCrowEW/bb60c314dd69cfc221728e5ca0b7f66a to your computer and use it in GitHub Desktop.
Save OldCrowEW/bb60c314dd69cfc221728e5ca0b7f66a 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