强制Jira传递工作流转换,不包括验证器和条件

时间:2016-01-12 12:37:51

标签: java workflow jira jira-plugin

我遇到了必须通过的Jira过渡问题。我有自动关闭Jira问题的服务(从已解决状态到关闭状态)。

它运行良好但是如果转换时出现任何条件或验证器(或脚本条件),则无法通过。 是否有任何方法可以通过转换,不包括验证器和条件? 以下是我的实际代码:

// issue service
IssueService issueService = ComponentAccessor.getIssueService();

//get user for passing transition           
user  = userUtil.getUserByKey(closeUserKey).getDirectoryUser();

//get issue object
Issue issueObj = ComponentAccessor.getIssueManager().getIssueObject(issueId);

// Parameters for issue
IssueInputParameters issueInputParams = new IssueInputParametersImpl();

//setting comment
issueInputParams.setComment("Issue closed by automatical service after specified time");

//avoid checking fields on screen and additional flag for default values
issueInputParams.setApplyDefaultValuesWhenParameterNotProvided(true);
issueInputParams.setSkipScreenCheck(true);

//validate if transition is ok
TransitionValidationResult validationResult = issueService.validateTransition(user, issueObj.getId(), closeStepId, issueInputParams);

//if is valid pass it               
if (validationResult.isValid()) {
    issueService.transition(user, validationResult);
    IssueService.IssueResult issueResult = issueService.transition(user, validationResult);

} else {
    System.out.println(validationResult.getErrorCollection().toString());
}

1 个答案:

答案 0 :(得分:0)

Automation插件可以跳过转换条件检查。它的来源是开放的,这就是它的作用:

import static com.atlassian.jira.workflow.TransitionOptions.Builder;
// ....
if (skipConditions)
{
    final TransitionOptions trasitionOptions = new Builder().skipPermissions().skipValidators().setAutomaticTransition().skipConditions().build();
    transitionValidationResult = issueService.validateTransition(user,
            mutableIssue.getId(), getTransitionId(actionId), params, trasitionOptions);
}