Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to update multiple labels as an array for a test case via jiraEditIssue using Jenkins file

Sudha
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 8, 2021

I am using jiraEditIssue to update labels for a test case in JIRA, but the following error is thrown.

ERROR: {"errorMessages":[],"errors":{"labels":"The label '[Label1, Label2]' contains spaces which is invalid."}}

 

Jenkins file uses groovy lang. In groovy on adding elements into a list, by default whitespaces are added between the elements of the list in groovy. On passing such a list in jiraEditIssue via Jenkins file, I notice jira has a problem in accepting whitespaces between the elements of an array/list.

Kindly let me know, how would I resolve the above mentioned issue.

Further details regarding the same are mentioned below

 

def labelValue = [] as String[]

/* Im fetching values from the code and adding them to the list

def label1 = "Label1"
def label2 = "Label2"
labelValue.add(label1.replaceAll(" ",""))

labelValue.add(label2.replaceAll(" ",""))

 

def testIssue = [fields:
[
 project: [key: "${projectKey}"],
 labels: ["${labelValue}"],
issuetype: [id: '10413']
]
]
response = jiraEditIssue idOrKey: testCaseID, issue: testIssue, site: 'ALM_JIRA'

 

1 answer

1 accepted

0 votes
Answer accepted
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 9, 2021

This is because you are converting a list to a string then making another list with that string as a single element.

Try 

def testIssue = [fields:
[
 project: [key: "${projectKey}"],
  labels: labelValue,
issuetype: [id: '10413']
]
]
Sudha
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 12, 2021

Thanks for the solution, it worked.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events