无法使用 Java 中的 ComponentRestClient 填充 JIRA 中的组件字段
Can't populate components field in JIRA using ComponentRestClient in Java
在 java 中使用 JiraRestClient 创建 JIRA 时,我一直在尝试不同的方法来填充组件字段,但不知何故无法做到这一点。
以下是我尝试过的方法之一 -
public String createIssue(String projectKey, Long issueType, String issueSummary, String description) throws URISyntaxException {
IssueRestClient issueClient = restClient.getIssueClient();
ComponentRestClient componentClient = restClient.getComponentClient();
String componentUrl = "https://jira.abc.com/issues/?jql=project+%3D+PROJECTKEY+AND+component+%3D+%22Comp+Name%22";
Component component = componentClient.getComponent(new URI(componentUrl.trim())).claim();
//BasicComponent bc = new BasicComponent();
IssueInput newIssue = new IssueInputBuilder(projectKey, issueType, issueSummary)
.setDescription(description).setComponents(component).build();
return issueClient.createIssue(newIssue).claim().getKey();
}
有了这个,我在 JSON 解析步骤 -
时出错
at org.codehaus.jettison.json.JSONTokener.syntaxError(JSONTokener.java:439) ~[jettison-1.1.jar:1.1]
at org.codehaus.jettison.json.JSONObject.<init>(JSONObject.java:169) ~[jettison-1.1.jar:1.1]
at org.codehaus.jettison.json.JSONObject.<init>(JSONObject.java:266) ~[jettison-1.1.jar:1.1]
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient.handle(AbstractAsynchronousRestClient.java:147) ~[jira-rest-java-client-core-4.0.0.jar:?]
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient.apply(AbstractAsynchronousRestClient.java:189) ~[jira-rest-java-client-core-4.0.0.jar:?]
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient.apply(AbstractAsynchronousRestClient.java:185) ~[jira-rest-java-client-core-4.0.0.jar:?]
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:81) ~[atlassian-httpclient-api-0.23.0.jar:?]
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:11) ~[atlassian-httpclient-api-0.23.0.jar:?]
at com.atlassian.util.concurrent.Promises$Of.apply(Promises.java:268) ~[atlassian-util-concurrent-2.4.2.jar:?]
at com.atlassian.util.concurrent.Promises.onSuccess(Promises.java:158) ~[atlassian-util-concurrent-2.4.2.jar:?]
at com.google.common.util.concurrent.Futures.run(Futures.java:1132) ~[guava-20.0.jar:?]
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:435) ~[guava-20.0.jar:?]
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:900) ~[guava-20.0.jar:?]
非常感谢任何帮助或建议!
这应该有效:
IssueInputBuilder builder = new IssueInputBuilder( projectKey, issueType, issueSummary );
Iterable<BasicComponent> components = restClient
.getProject( projectKey )
.getComponents( );
for ( BasicComponent c : components ) {
if ( c.getName().equals( "your component name" ) ) {
builder.setComponents( c ); // assuming you want only one component
}
}
IssueInput newIssue = builder.setDescription(description).build(); // etc...
在 java 中使用 JiraRestClient 创建 JIRA 时,我一直在尝试不同的方法来填充组件字段,但不知何故无法做到这一点。 以下是我尝试过的方法之一 -
public String createIssue(String projectKey, Long issueType, String issueSummary, String description) throws URISyntaxException {
IssueRestClient issueClient = restClient.getIssueClient();
ComponentRestClient componentClient = restClient.getComponentClient();
String componentUrl = "https://jira.abc.com/issues/?jql=project+%3D+PROJECTKEY+AND+component+%3D+%22Comp+Name%22";
Component component = componentClient.getComponent(new URI(componentUrl.trim())).claim();
//BasicComponent bc = new BasicComponent();
IssueInput newIssue = new IssueInputBuilder(projectKey, issueType, issueSummary)
.setDescription(description).setComponents(component).build();
return issueClient.createIssue(newIssue).claim().getKey();
}
有了这个,我在 JSON 解析步骤 -
时出错at org.codehaus.jettison.json.JSONTokener.syntaxError(JSONTokener.java:439) ~[jettison-1.1.jar:1.1]
at org.codehaus.jettison.json.JSONObject.<init>(JSONObject.java:169) ~[jettison-1.1.jar:1.1]
at org.codehaus.jettison.json.JSONObject.<init>(JSONObject.java:266) ~[jettison-1.1.jar:1.1]
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient.handle(AbstractAsynchronousRestClient.java:147) ~[jira-rest-java-client-core-4.0.0.jar:?]
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient.apply(AbstractAsynchronousRestClient.java:189) ~[jira-rest-java-client-core-4.0.0.jar:?]
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient.apply(AbstractAsynchronousRestClient.java:185) ~[jira-rest-java-client-core-4.0.0.jar:?]
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:81) ~[atlassian-httpclient-api-0.23.0.jar:?]
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:11) ~[atlassian-httpclient-api-0.23.0.jar:?]
at com.atlassian.util.concurrent.Promises$Of.apply(Promises.java:268) ~[atlassian-util-concurrent-2.4.2.jar:?]
at com.atlassian.util.concurrent.Promises.onSuccess(Promises.java:158) ~[atlassian-util-concurrent-2.4.2.jar:?]
at com.google.common.util.concurrent.Futures.run(Futures.java:1132) ~[guava-20.0.jar:?]
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:435) ~[guava-20.0.jar:?]
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:900) ~[guava-20.0.jar:?]
非常感谢任何帮助或建议!
这应该有效:
IssueInputBuilder builder = new IssueInputBuilder( projectKey, issueType, issueSummary );
Iterable<BasicComponent> components = restClient
.getProject( projectKey )
.getComponents( );
for ( BasicComponent c : components ) {
if ( c.getName().equals( "your component name" ) ) {
builder.setComponents( c ); // assuming you want only one component
}
}
IssueInput newIssue = builder.setDescription(description).build(); // etc...