Clone wiki

runner / Post-functions

#Custom Workflow Functions Customise and extend your workflows using complex scripts to support or enforce your business processes. ##Binding For each type of workflow function, the plugin will provide the current $issue, $currentUser, $transientVars, $args, $propertySet and $log in the script binding. That means you can refer to them using these variables, without declaring them.

##Post-Functions Post-functions execute after the transition has been validated. Here is the place where you can pass on a message to a downstream system, send custom notifications or modify the issue etc.

###Examples * GROOVY

A post-function to add comment

import com.atlassian.jira.component.ComponentAccessor

def commentManager = ComponentAccessor.getCommentManager();
def user = $issue.reporterId
def comment = "This is a new comment"
  • PHP
$issue->key; $issue->isSubTask();
$transientVars->pkey; $transientVars->actionId; $transientVars["project"]->lead; $transientVars["comment"];
$log->warn("Hello atlassian-jira.log!");

A post-function to resolve a parent issue.

// this should go to the inline script as parameters for the transition.php.
$actionId = 5; // resolve issue
$targetIssue = $issue->parentObject;
$inputParameters = [];

// this should be reusable transition.php
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.util.ImportUtils;
import com.atlassian.jira.issue.IssueInputParametersImpl;

if (!$inputParameters)
    $inputParameters = [];
$issueInputParameters = new IssueInputParametersImpl($inputParameters);

if (!$targetUser)
    $targetUser = $currentUser;

$log->debug("transitionning ${targetIssue} as ${targetUser}, action: ${actionId}, inputParameters:${inputParameters}");

$indexManager = jira_component("com.atlassian.jira.issue.index.IssueIndexManager");
$issueService = ComponentAccessor::getIssueService();

$validationResult = $issueService->validateTransition($targetUser, $targetIssue->id, $actionId, $issueInputParameters);
$isValid = $validationResult->isValid();
$errorCollection = $validationResult->errorCollection;

if (!$isValid) {
    $log->error("Transition not validated, errorCollection:${errorCollection}");

$errorCollection = $issueService->transition($targetUser, $validationResult)->errorCollection;

if ($errorCollection->hasAnyErrors()) {
    $log->error("Transition failed, errorCollection:${errorCollection}");

// reload issue
$targetIssue = ComponentAccessor::getIssueManager()->getIssueObject($targetIssue->id);
$wasIndexing = ImportUtils::isIndexIssues();

A post-function to Send Custom Email.