Created by Joaquin Fernandez 2022-06-16 View revision File snippet.txt Added Side-by-side diff More Ignore whitespace Hide word diff +//Find and store the attachment names in a paragrahp custom field +def issueKey = 'NOT-1' + +def result = get('/rest/api/2/issue/' + issueKey) + .header('Content-Type', 'application/json') + .asObject(Map) + + +def filenames = result.body.fields.attachment.filename.join(", ") + + +def result2 = put('/rest/api/2/issue/' + issueKey) + .header('Content-Type', 'application/json') + .body([ + fields:[ + customfield_10079: filenames + ] +]) + .asString() + + +if (result2.status >= 200 && result2.status<300){ + return filenames +} else { + return "Failed to update custom field with the attachment names" +}