[JIRA] (JENKINS-59760) "Fields" parameter does not work with jiraJqlSearch

8 views
Skip to first unread message

szhemzhitski@gmail.com (JIRA)

unread,
Oct 12, 2019, 11:02:03 AM10/12/19
to jenkinsc...@googlegroups.com
Sergey Zhemzhitsky created an issue
 
Jenkins / Bug JENKINS-59760
"Fields" parameter does not work with jiraJqlSearch
Issue Type: Bug Bug
Assignee: Naresh Rayapati
Components: jira-steps-plugin
Created: 2019-10-12 15:01
Environment: JIRA Cloud
Priority: Major Major
Reporter: Sergey Zhemzhitsky

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"
      }
    }
  ]
}
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

naresh.rayapati@gmail.com (JIRA)

unread,
Jan 28, 2020, 11:14:03 PM1/28/20
to jenkinsc...@googlegroups.com
Naresh Rayapati commented on Bug JENKINS-59760
 
Re: "Fields" parameter does not work with jiraJqlSearch

Released with 1.5.3, pass fields as array or similar to how it has been sent in REST API, it should work.

PR: https://github.com/jenkinsci/jira-steps-plugin/pull/100

naresh.rayapati@gmail.com (JIRA)

unread,
Jan 28, 2020, 11:14:05 PM1/28/20
to jenkinsc...@googlegroups.com
Naresh Rayapati closed an issue as Fixed
 
Change By: Naresh Rayapati
Status: Open Closed
Resolution: Fixed

naresh.rayapati@gmail.com (JIRA)

unread,
Jan 28, 2020, 11:15:03 PM1/28/20
to jenkinsc...@googlegroups.com
Naresh Rayapati updated an issue
Change By: Naresh Rayapati
Labels: jira-steps-plugin-1.5.3
Reply all
Reply to author
Forward
0 new messages