Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Summary

SINCE JEMH 4.2.12

Post-Functions are used as part of a Jira project workflow.  When transitioning from one workflow step to another (e.g. "Open" to "In Progress"), Post Functions can be added to execute within the transition.

The JEMH Script Postfunction allows some issue operations to be made using available script engines (Nashhorn, Groovy).

Edit time screenshot

image-20240703-131027.png

Preview

The preview feature allows the script to be evaluated in the context of the issue you define. Debug (via print(“nnn”)) output will be shown on screen and will also be logged in the JEMH log (see Enabling JEMH logging ).

Example code

Goal

Code Snippet

append “[UPDATED]” and the current date to an issue summary. Then set the priority of the issue to the highest.

print('issue: '+issue.getKey());
print('issueSummary: '+issue.getSummary());
var updatedSummary=issue.getSummary()+" [UPDATED] "+new Date().toString();
print('updating issue to: '+updatedSummary);
issue.setSummary(updatedSummary);
issue.setPriorityId(1);

add all the pinned comments of an issue to the issues description.

adminUser = userManager.getUserByName("admin");
if (adminUser !== null) {
    pinnedComments = commentManager.getPinnedComments(issue, adminUser);
    var description = "";
    for (i = 0; i < pinnedComments.length; i++) {
        description = description + pinnedComments[i].getComment().getBody() + "\n";
    }
    issue.setDescription(description);
}

Set an assignee of an issue, if the user “user1” exists. When the user doesn’t exist, sets the assignee of the issue as admin.

user = userManager.getUserByName("user1");
if (user !== null) {
    issue.setAssignee(user);
} else {
    adminUser = userManager.getUserByName("admin");
    issue.setAssignee(adminUser);
}

Context

The classes available in the context are limited. Log a Support ticket if you need to do something else:

Key

Class

Value (text)

Integer

java.lang.Class

class java.lang.Integer

Long

java.lang.Class

class java.lang.Long

applicationProperties

com.atlassian.jira.config.properties.ApplicationPropertiesImpl

com.atlassian.jira.config.properties.ApplicationPropertiesImpl

baseurl

java.lang.String

http://localhost:8080

commentManager

com.atlassian.jira.issue.comments.DefaultCommentManager

com.atlassian.jira.issue.comments.DefaultCommentManager

customFieldManager

com.atlassian.jira.issue.managers.CachingCustomFieldManager

com.atlassian.jira.issue.managers.CachingCustomFieldManager

dateFormatter

com.atlassian.jira.web.util.OutlookDate

com.atlassian.jira.web.util.OutlookDate

groupManager

com.javahollic.jira.emh.service.security.SafeGroupManager

com.javahollic.jira.emh.service.security.SafeGroupManager

issueLinkService

com.atlassian.jira.bc.issue.link.DefaultIssueLinkService

com.atlassian.jira.bc.issue.link.DefaultIssueLinkService

issueManager

com.atlassian.jira.issue.managers.RequestCachingIssueManager

com.atlassian.jira.issue.managers.RequestCachingIssueManager

jemhDateUtils

com.javahollic.jira.emh.velocity.JemhDateUtils

com.javahollic.jira.emh.velocity.JemhDateUtils

jemhVersion

java.lang.String

4.2.12

jqlQueryBuilder

com.atlassian.jira.jql.builder.JqlQueryBuilder

com.atlassian.jira.jql.builder.JqlQueryBuilder

log

org.apache.log4j.Logger

org.apache.log4j.Logger

  • No labels