You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hetzner-ansible/smardigo/provisioning/script/create-teams-message.groovy

45 lines
1.7 KiB
Groovy

def smardigoUrl = "https://" + cluster.stage + "-management-smardigo-01-connect.smardigo.digital/api/redirect/process/" + contextScopeId + "/dossier/simple-connect/" + contextProcessId
def smardigoMessageUrl = "https://" + cluster.stage + "-management-smardigo-01-connect.smardigo.digital/api/v1/scopes/" + contextScopeId + "/processes/" + contextProcessId + "/messages"
def message = [:]
message["@type"] = "MessageCard"
message["@context"] = "http://schema.org/extensions"
message["themeColor"] = "0076D7"
message["summary"] = "Neue Aufgabe: " + comment
def section = [:]
section["activityTitle"] = activityTitle
section["activitySubtitle"] = activitySubtitle
section["activityImage"] = "https://smardigo.de/wp-content/uploads/2020/01/smardigo-min.png"
section["facts"] = [
[name:"Stage",value:cluster.stage],
[name:"Name",value:cluster.name],
[name:"Service",value:cluster.service],
[name:"Mandant",value:tenant.name]
]
message.sections = [section]
def potentialAction = []
def openInSmardigo = [:]
openInSmardigo["@type"] = "ViewAction"
openInSmardigo["@context"] = "http://schema.org"
openInSmardigo["name"] = "Vorgang öffnen"
openInSmardigo["target"] = [smardigoUrl]
potentialAction.add(openInSmardigo)
if (vorgang_status < 30) {
def approveInSmardigo = [:]
approveInSmardigo["@type"] = "HttpPOST"
approveInSmardigo["name"] = "Server freigeben"
approveInSmardigo["target"] = smardigoMessageUrl
approveInSmardigo["body"] = "{\"message\":\"process-approved-" + contextProcessId + "\"}"
approveInSmardigo["headers"] = [
[name:"Smardigo-User-Token",value:envSmardigoUserToken]
]
potentialAction.add(approveInSmardigo)
}
message.potentialAction = potentialAction
message