Remove spaces from Rally Tags to be able to sync them to Jira Labels
search cancel

Remove spaces from Rally Tags to be able to sync them to Jira Labels


Article ID: 273980


Updated On:




When syncing Rally Tags to Jira Labels, if there is space in Rally Tags(as Rally allows spaces in Tags), the Tags will not sync to Jira and throw an error saying the spaces are not allowed in Labels.


Release : 2.11.x to 3.2.0


The issue is because Jira does not allow spaces in Labels.


Below Business Script can take care of this use case.
The steps outlined in the Article can be followed to set up the Business logic for this use case. Below is the groovy script that can help you achieve this.

Execution Type = PRE_MAPVALUE

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import com.go2group.connectall.config.model.bean.*;

println "Applying Custom Business Rules RemoveSpacesFromRallyTags";

// Part I - Cancate TAGS in a single string to be able to remove spaces.

def _tags = message.payload.getValuesList("Tags");
println "Origional Rally Tags value is " + _tags;

def tags = []

if (_tags) {
    def tagPattern = /\[Name : (.*?)\]/
    tags = (_tags =~ tagPattern).collect { it[1].trim() }

def tagString = tags.join(',')
def delemitedString = tagString.replaceAll(" ","_")
def _delimiter = ',';

println delemitedString;

// Part II - Set the updated Tags with spaces removed in the payload.

            // Split the delimited string to Tags
            def splitLables = delemitedString.split(_delimiter)
            def valueList = Value.getValues(splitLables)

println "This is from ValueList" + valueList;

return message.payload;