我正在寻找在JIRA中设置智能提交,但我的开发人员想知道他们过渡的所有选项。为了帮助他们,我想打印一份所有过渡名称的备忘单(我相信他们足够聪明,可以弄清楚从那里做什么)。
但是当我查看REST API文档时,我只能找到一种方法来获取list of transitions for a particular issue(可能是通过其状态)。有没有办法获得任何故障单可以在其工作流程中的任何点采取的所有转换列表?
答案 0 :(得分:2)
您可以通过此端点列出给定故障单的过渡:
/rest/api/2/issue/${issueIdOrKey}/transitions
更深入的解释请看这里: Does the JIRA REST API require submitting a transition ID when transitioning an issue?
答案 1 :(得分:1)
您可以使用/rest/api/2/project/{projectIdOrKey}/statuses端点获取项目的所有转换。这是响应示例,请查看"状态"阵列:
[
{
"self": "http://localhost:8090/jira/rest/api/2.0/issueType/3",
"id": "3",
"name": "Task",
"subtask": false,
"statuses": [
{
"self": "http://localhost:8090/jira/rest/api/2.0/status/10000",
"description": "The issue is currently being worked on.",
"iconUrl": "http://localhost:8090/jira/images/icons/progress.gif",
"name": "In Progress",
"id": "10000"
},
{
"self": "http://localhost:8090/jira/rest/api/2.0/status/5",
"description": "The issue is closed.",
"iconUrl": "http://localhost:8090/jira/images/icons/closed.gif",
"name": "Closed",
"id": "5"
}
]
}
]
但它并没有为您提供任何问题随时可以采用的转换列表,而且我不确定API中是否存在此类方法。
答案 2 :(得分:0)
public void changeStatus(IssueRestClient iRestClient,
List<Statuses> JiraStatuses, String key) {
String status = "To Do";
for (Statuses statuses : vOneToJiraStatuses) {
if (1 == statuses.compareTo(status)) {
try {
String _transition = statuses.getTransition();
Issue issue = iRestClient.getIssue(key).get();
Transition transition = getTransition(iRestClient, issue,
_transition);
if (!(isBlankOrNull(transition))) {
if (!(issue.getStatus().getName()
.equalsIgnoreCase(_transition)))
transition(transition, issue, null, iRestClient,
status);
}
} catch (Exception e) {
Constants.ERROR.info(Level.INFO, e);
}
break;
}
}
}
List是一个pojo实现,其中xml中定义的状态和转换是通过setter / constructor注入的。
private void transition(Transition transition, Issue issue,
FieldInput fieldInput, IssueRestClient issueRestClient,
String status) throws Exception {
if (isBlankOrNull(fieldInput)) {
TransitionInput transitionInput = new TransitionInput(
transition.getId());
issueRestClient.transition(issue, transitionInput).claim();
Constants.REPORT.info("Status Updated for : " + issue.getKey());
} else {
TransitionInput transitionInput = new TransitionInput(
transition.getId());
issueRestClient.transition(issue, transitionInput).claim();
Constants.REPORT.info("Status Updated for : " + issue.getKey());
}
}
public Transition getTransition(IssueRestClient issueRestClient,
Issue issue, String _transition) {
Promise<Iterable<Transition>> ptransitions = issueRestClient
.getTransitions(issue);
Iterable<Transition> transitions = ptransitions.claim();
for (Transition transition : transitions) {
if (transition.getName().equalsIgnoreCase(_transition)) {
return transition;
}
}
return null;
}
简而言之,使用JIRA的Transition API,我们可以获取所有转换来设置状态