Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Jenkins pipeline and JIRA: Add multiple lables to issue

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


2 answers

1 accepted

0 votes
Answer accepted

Simple solution

String[] myLabels = jiraLabels.split(",")
try {
def modIssue = [fields: [
project: [key: jiraProjectKey],
labels: myLabels
response = jiraEditIssue idOrKey: currentIssueKey, issue: modIssue
0 votes
Tarun Sapra Community Leader Sep 12, 2018

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"} ] } }

Yeah but I don't use the REST api directly but rather the jenkins plugin.

@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

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"]])                    }                }

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you