How to sync remote labes to local with adding prefix to local?

Originally asked by Helen Li on 24 August 2021 (original question)


Dear sir,

I have a use case as below:

Remote server will sync all the lables which contains “mustfix”. eg, sop_mustfix, mustfix_xxx, xxx_mustfix_yyy.

Our local incoming script need add prefix “sync_” to all the labels. How to implement it?

remote Local

sop_mustfix, mustfix_xxx, xxx_mustfix_yyy sync_sop_mustfix, sync_mustfix_xxx, sync_xxx_mustfix_yyy

if(replica.labels.collect{it.label}.contains(“mustfix”)){

issue.labels += replica.labels.collect { it.label = it.label.replace(" ", “sync_”); it } //I do not know how to add the prefix here

}

else //if remote delete the label, we also need delete

{

if( (replica.labels.label.join(" “)==”") && (issue.labels.findAll { it.label.contains(“sync_”) }) )

issue.labels \= issue.labels\-nodeHelper.getLabel***("????")    //I do not know how to clear the lable***

}

Best regards,

Helen