-
Bug
-
Resolution: Fixed
-
Major
-
JIRA Cloud
It seems that "fields" parameter does not work with jiraJqlSearch or at least it's unclear how it should be used properly.
Here is the query to get 3 issues with key and summary fields only
def issues = jiraJqlSearch( jql: "project='AM'", fields: 'key,summary', site: 'jira', maxResults: 3 )
and this snippet returns the following error
[Pipeline] jiraJqlSearch JIRA: Site - jira - Search JQL: project='AM' startAt: 0 maxResults: 3 Error Code: 400 Error Message: {"errorMessages":["Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token\n at [Source: org.apache.catalina.connector.CoyoteInputStream@2e4bdc21; line: 1, column: 51] (through reference chain: com.atlassian.jira.rest.v2.search.SearchRequestBean[\"fields\"])"]}
Trying to pass fields as array like the following
def issues = jiraJqlSearch( jql: "project='AM'", fields: ['key','summary'], site: 'jira', maxResults: 3 )
leads to the following error
[Pipeline] End of Pipeline java.lang.ClassCastException: class org.thoughtslive.jenkins.plugins.jira.steps.JqlSearchStep.fields expects class java.lang.String but received class java.util.ArrayList at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:492) at org.jenkinsci.plugins.structs.describable.DescribableModel.injectSetters(DescribableModel.java:429) at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:331) at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:269) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:179) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122) at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810) at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46) at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20) Caused: java.lang.IllegalArgumentException: Could not instantiate {jql=project='AM', fields=[key, summary], site=jira, maxResults=3} for org.thoughtslive.jenkins.plugins.jira.steps.JqlSearchStep at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:334) at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:269) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:179) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
At the same time this curl sample works as expected without any errors
$ curl -XGET -H'Accept:application/json' -u 'user:pass' 'https://company.atlassian.net/rest/api/2/search?jql=project%3DAM&maxResults=3&fields=key,summary' | jq . { "expand": "schema,names", "startAt": 0, "maxResults": 3, "total": 2857, "issues": [ { "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields", "id": "52769", "self": "https://company.atlassian.net/rest/api/2/issue/52769", "key": "AM-2889", "fields": { "summary": "Issue 1" } }, { "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields", "id": "52768", "self": "https://company.atlassian.net/rest/api/2/issue/52768", "key": "AM-2888", "fields": { "summary": "Issue 2" } }, { "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields", "id": "52753", "self": "https://company.atlassian.net/rest/api/2/issue/52753", "key": "AM-2887", "fields": { "summary": "Issue 3" } } ] }