DevGenius1 / Scripts

1 stars 1 forks source link

add form to issue #63

Open Bhavya-ss opened 4 months ago

Bhavya-ss commented 4 months ago

import java.util.Base64

def issueKey = issue.key// Replace with the actual issue key def cloudId = "df95781f-2e2a-34fb6c2d7" def username = 'xyz@gmail.com' def apiToken = 'xxxx' // Use API token instead of password def authString = "${username}:${apiToken}".getBytes("UTF-8").encodeBase64().toString() def requestType = issue.fields.customfield_10010?.requestType?.name

if (requestType == "Fix an account problem") {

def result = post("https://api.atlassian.com/jira/forms/cloud/${cloudId}/issue/${issueKey}/form") .header("Authorization", "Basic ${authString}") .header('Content-Type', 'application/json') .body([ formTemplate: [ id: "f41ba59a-1781-4eq2411c96" ] ]) .asString()

}

// to get form uuid / curl --request GET \ --url 'https://api.atlassian.com/jira/forms/cloud/{CloudId}/servicedesk/{serviceDeskId}/requesttype/{requestTypeId}/form' \ --user 'email@example.com:' \ --header 'Accept: application/json' /

Bhavya-ss commented 4 months ago

Map<String, Object> issueResult = get("/rest/api/2/issue/${issue.key}") .queryString('fields', 'fixVersions') .asObject(Map) .body def fixVersions = ((List<Map<String, Object>>) issueResult.fields.fixVersions)?.collect { version -> version.name } return fixVersions as String