Never entering Lable loop of groovy script

We have a groovy script in post function where we want to act if either of two specific labels are present.  The script runs without throwing any errors and it produces the expected log entries but nor does it enter the for loop for the labels.  What am I doing incorrectly?

 

import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.issue.label.Label


def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)


boolean ReporterIsJiraUser = 1;
log.debug "AAAAA issue is " + issue.key + " " + issue.reporter.name

boolean IssueType = 0;
log.debug "AAAAA issue is " + issue.key + " " + issue.reporter.name + " IssueType is false " + IssueType
if ( issue.issueType.name == 'Help' ){ IssueType=1; }
log.debug "AAAAA issue is " + issue.key + " " + issue.reporter.name + " IssueType is now? " + IssueType

Set<Label> issueLabels = issue.getLabels();
boolean containsLabel = 0;

log.debug "AAAAA issue is " + issue.key + " " + issue.reporter.name + " ContainsLabel is false " + containsLabel

for ( Label label : issueLabels) {
    log.debug "AAAAA issue is " + issue.key + "In the for label loop"
    if (label.getLabel()== "created-by-jemh") {
        log.debug "AAAAA issue is " + issue.key + "In the for label loop - found jemh label"
        containsLabel = 1;
    }
    if (label.getLabel() == "collector-dfbeb230") {
        containsLabel = 1;
    }
}

if (containsLabel && IssueType){ return 1; }
else { return 0; }

Thanks in advance!

1 answer

This widget could not be displayed.

If you use the log.debug to spit out the content of issueLabels after you ask the issue for all the labels, do you get anything in the log?  (If you do, it'll probably be ugly to read, but it might tell us something!)

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

54 views 1 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you