73 lines
2.4 KiB
Groovy
73 lines
2.4 KiB
Groovy
// -----------------------------------------------------------------------------
|
||
// Postfunction: Setzt LabelManager-Feld, Security-Level, Dropdown-Wert,
|
||
// leert ein Multi-User-Feld und setzt ein anderes Multi-User-Feld auf den Assignee
|
||
// -----------------------------------------------------------------------------
|
||
|
||
// LabelManager-Konfiguration
|
||
final LABEL_MANAGER_CF_ID = 'customfield_11037'
|
||
final SELECTED_LABEL = 'Partneranfrage-Angenommen'
|
||
final LABEL_COLOR = 'green'
|
||
final LABEL_SOURCE = 'project'
|
||
|
||
// Security-Level "CS"
|
||
final SECURITY_LEVEL_ID = '10125'
|
||
|
||
// Dropdown-Feld (Single Select)
|
||
final DROPDOWN_CF_ID = 'customfield_10039'
|
||
final DROPDOWN_VALUE = 'Customer Service'
|
||
|
||
// Multi-User-Felder
|
||
final USERFIELD_CLEAR_ID = 'customfield_10054' // Partner Bearbeiter wird geleert
|
||
final USERFIELD_SET_ID = 'customfield_10036' // pds Bearbeiter wird auf Assignee gesetzt
|
||
|
||
// Issue-Key aus dem Workflow-Kontext
|
||
def issueKey = issue.key
|
||
def assignee = issue.fields.assignee
|
||
|
||
// Wenn kein Assignee vorhanden ist, Log-Eintrag
|
||
if (!assignee) {
|
||
logger.warn "Kein Assignee für ${issueKey} vorhanden – ${USERFIELD_SET_ID} bleibt leer."
|
||
}
|
||
|
||
// Request-Body zusammensetzen
|
||
def payload = [
|
||
fields: [
|
||
// LabelManager-Feld
|
||
(LABEL_MANAGER_CF_ID): [
|
||
labels : [SELECTED_LABEL],
|
||
colors : [LABEL_COLOR],
|
||
labelSource: LABEL_SOURCE
|
||
],
|
||
|
||
// Security-Level
|
||
security: [
|
||
id: SECURITY_LEVEL_ID
|
||
],
|
||
|
||
// Dropdown-Feld (Single Select)
|
||
(DROPDOWN_CF_ID): [
|
||
value: DROPDOWN_VALUE
|
||
],
|
||
|
||
// Multi-User-Feld leeren
|
||
(USERFIELD_CLEAR_ID): [],
|
||
|
||
// Multi-User-Feld auf aktuellen Assignee setzen (falls vorhanden)
|
||
(USERFIELD_SET_ID): assignee ? [[ accountId: assignee.accountId ]] : []
|
||
]
|
||
]
|
||
|
||
// PUT-Request an Jira REST API
|
||
def response = put("/rest/api/3/issue/${issueKey}")
|
||
.header('Content-Type', 'application/json')
|
||
.body(payload)
|
||
.asString()
|
||
|
||
// Erfolg / Fehler protokollieren
|
||
if (response.status == 204) {
|
||
logger.info "Felder erfolgreich aktualisiert für ${issueKey}: Label='${SELECTED_LABEL}', Security=CS, Dropdown='${DROPDOWN_VALUE}', " +
|
||
"${USERFIELD_CLEAR_ID} geleert, ${USERFIELD_SET_ID} auf Assignee gesetzt."
|
||
} else {
|
||
logger.warn "Update fehlgeschlagen (${response.status}) für ${issueKey}: ${response.body}"
|
||
}
|