Hey everyone, I’m new to Jira but been Dev for years. I’ve started out with some automated comments that @ mention specific roles on status transitions. I’m using the jacson library to create the ADF.
The issue I have is that in Jira, the new line \n works as expected when I run this code on a Post Function on a workflow. (e.g. it transitions from one status to the next)
Code: (mentions assignee)
logger.info("DEBUG - Mention email NOT formatting ADF with new lines")
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
// The payload definition using the Jackson library
JsonNodeFactory jnf = JsonNodeFactory.instance;
ObjectNode payload = jnf.objectNode();
ObjectNode body = payload.putObject("body");
body.put("type", "doc");
body.put("version", 1);
ArrayNode contentArray = body.putArray("content");
ObjectNode content0 = contentArray.addObject();
content0.put("type", "paragraph");
ArrayNode paragraphArray = content0.putArray("content");
ObjectNode paragraph0 = paragraphArray.addObject();
paragraph0.put("type", "text");
paragraph0.put("text", "[DEBUG - Not putting in new lines in email only]\n");
ArrayNode marksArray = paragraph0.putArray("marks")
ObjectNode marks0 = marksArray.addObject();
marks0.put("type","strong")
logger.info("Assignee:" + issue.fields.assignee.displayName);
ObjectNode paragraph1 = paragraphArray.addObject();
paragraph1.put("type", "mention");
ObjectNode attrs0 = paragraph1.putObject("attrs");
attrs0.put("id", issue.fields.assignee.accountId);
attrs0.put("text", "@" + issue.fields.assignee.displayName);
attrs0.put("userType", "APP");
ObjectNode paragraph2 = paragraphArray.addObject();
paragraph2.put("type", "text");
paragraph2.put("text", " is the Assigned User.\n There should also be a new line here.");
logger.info("Body: " + payload.toString())
def result = post("/rest/api/3/issue/${issue.key}/comment")
.header('Content-Type', 'application/json')
.body(payload.toString())
.asString()
if (result.status == 204) {
return 'Success'
} else {
return "${result.status}: ${result.body}"
}
In Jira - the new lines in the ADF work fine.
In Email - the new lines are not being rendered?
Is there something I’m missing here? I’ve tried a couple of different approaches to the API, but both give this same result?