强制 Jira 通过工作流转换,不包括验证器和条件
Forcing Jira to pass workflow transition excluding validators and conditions
我必须通过 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());
}
自动化插件能够跳过转换条件检查。它的来源是开放的,它是这样的:
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);
}
我必须通过 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());
}
自动化插件能够跳过转换条件检查。它的来源是开放的,它是这样的:
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);
}