I have string (comme separated values) of labels which I want to add to an existing issue using jiraEditIssue within a Jenkins pipeline. The labels are defined as follows
jiraLabels = "Label1,Label2,Label3"
So how to I add all lables to the issue
def modIssue = [fields: [
project: [key: jiraProjectKey],
labels: [ jiraLabels ]
]]
response = jiraEditIssue idOrKey: currentIssueKey, issue: modIssue
Simple solution
String[] myLabels = jiraLabels.split(",")
try {
def modIssue = [fields: [
project: [key: jiraProjectKey],
labels: myLabels
]]
response = jiraEditIssue idOrKey: currentIssueKey, issue: modIssue
Hello @Adrian Wyssmann
For the labels you might have to use the "add attribute" as it's an array field.
Please see here
{ "update": { "labels": [ {"add": "newlabel"} ] } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah but I don't use the REST api directly but rather the jenkins plugin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Adrian Wyssmann - I am also using the jenkins plugin, but unable to add labels. I am able to add comments to jira but not labels. Not using the rest api. Were you able to solve this issue? @Tarun Sapra Using Jira Cloud with Jenkins Pipeline, if that makes any difference
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is the code snippet:
stage('jira comment') { steps{ step([$class: 'hudson.plugins.jira.JiraIssueUpdater', issueSelector: [$class: 'hudson.plugins.jira.selector.DefaultIssueSelector'], scm: scm, labels: ["IN-DEV"]]) } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.