Questions for Confluence license has expired.

Please purchase a new license to continue using Questions for Confluence.

How to remove leading white space from ADO labels array

 
1
0
-1

We are experiencing an issue with our outgoing sync from ADO to Jira Cloud. When the workItem.labels collection has more than one label in it all labels except the first one gets a leading space. I've tried this:
 
replica.labels = workItem.labels.collect { label -> 
    def ml = label.value.trim()
    def nLabel = new com.exalate.basic.domain.hubobject.v1.BasicHubLabel().setLabel(ml)
    label = nLabel
}

this causes no error but the output is still this:

"labels": [
      {
        "label": "Label1"
      },
      {
        "label": " Label2"
      }
    ],
    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hello Sebastian,


      You can place the following code in the Outgoing Sync on Azure DevOps. It will remove (trim) the whitespaces at the beginning and end of the string, and it will replace the spaces between words for an underscore.


      Example:

      ADO: " Label Test" →. Jira: "Label_Test"


      replica.labels = workItem.labels.collect { it.label = it.label.trim().replace(" ", "_"); it }


      Kind regards,

      Javier

        CommentAdd your comment...