目录
问题:
目前工作中遇到的一个问题是需要修改JIRA上面问题单的一个自定义的下拉状态:
目前的做法:
1.手工修改所有状态,然后通过JiraRestClient查询到对应isuue对应状态的值:
其中一个状态为:
IssueField{id=customfield_13XXX1, name=XXXX状态, type=null, value={"self":"https:\/\/XXXXXXXXX\/rest\/api\/2\/customFieldOption\/18XXX3","value":"XXXXX通过","id":"18XX3"}},
2.通过代码修改成需要修改的状态:
/**
* @Description 测试修改jira下拉状态
* @Author nakey
* @Date 2021/8/20 15:26
* @param
* @return void
*/
@Test
public void testUpdateState() throws JSONException {
AsynchronousJiraRestClientFactory asynchronousJiraRestClientFactory = new AsynchronousJiraRestClientFactory();
JiraRestClient jiraRestClient = asynchronousJiraRestClientFactory.
createWithBasicHttpAuthentication(URI.create("https://jira.xxxx.com/"),
"xxxxx","*********");
//此处是需要查询的issuekey
Issue issue = jiraRestClient.getIssueClient().getIssue("xxxx-xxxx").claim();
//获取某状态数据
//IssueField issueField = issue.getField("customfield_xxxxx");
//修改成某状态
HashMap<String,Object> valuesMap = new HashMap<>();
valuesMap.put("self","xxxxx");
valuesMap.put("value","某状态名称");
valuesMap.put("id","xxx");
ComplexIssueInputFieldValue complexIssueInputFieldValue = new ComplexIssueInputFieldValue(valuesMap);
FieldInput fieldInput = new FieldInput("customfield_xxxxx", complexIssueInputFieldValue);
IssueInput issueInput = IssueInput.createWithFields(fieldInput);
jiraRestClient.getIssueClient().updateIssue(issue.getKey(),issueInput);
System.out.println("修改完毕!");
}
总结
由于目前在网上还没有类似代码,我也是自己看源码慢慢试的,希望能帮到有需要的人!