Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

How to get debugging messages with variables out of scriptrunner in listener?


I am trying to obtain a debugging message for a scriptrunner listener. It should contain variables. The code is here:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Options
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.label.LabelManager
import com.atlassian.jira.issue.label.Label
import com.atlassian.jira.issue.customfields.option.*
import org.apache.log4j.Level
import org.apache.log4j.Logger
import org.slf4j.LoggerFactory;


def customFieldManager = ComponentAccessor.getComponent(CustomFieldManager)
def optionsManager = ComponentAccessor.getOptionsManager()

def issue = event.getIssue() as MutableIssue
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManager = ComponentAccessor.getIssueManager()

def customFieldTeam = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Team")
def customFieldTeamLabels = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Team Labels")
def labelMgr = ComponentAccessor.getComponent(LabelManager)
def existing_labels = (List <Option>) issue.getCustomFieldValue(customFieldTeamLabels)
log.debug("My variable has a value: " + existing_labels)
if(event.getChangeLog().getRelated("ChildChangeItem").find{ it.field == "Team" && it.newstring == "my_new_label"}){

for (label in existing_labels) {
log.debug("The labels are: " + label)
issue.setCustomFieldValue(customFieldTeamLabels, [label] as Set)

def my_new_label= new Label(null,, customFieldTeamLabels.idAsLong, "my_new_label")

issue.setCustomFieldValue(customFieldTeamLabels, [my_new_label] as Set)



The above should hopefully print all the labels inside the "existing_labels" variable, but it does not do that at all. The same goes for "label".

Thank you!

1 answer

1 accepted

0 votes
Answer accepted

HI @AramaM 

Do you get any logs output at all from your script?

When I run it in my groovy console (after small modification to manually get an issue and remove the event.getChangeLogCondition), I get this:

2020-03-03 22:22:08,089 DEBUG [runner.AbstractScriptRunner]: ... 
2020-03-03 22:22:08,092 DEBUG [runner.AbstractScriptRunner]: My variable has a value: [test2, testlabel]
2020-03-03 22:22:08,092 DEBUG [runner.AbstractScriptRunner]: The labels are: test2
2020-03-03 22:22:08,093 DEBUG [runner.AbstractScriptRunner]: The labels are: testlabel

 Where are you looking for the log output? If in scriptrunner history, I'd check directly in your atlassian-jira.log file to make sure it's not a problem with scriptrunner history.

Hi Peter, 

Thank you for your reply.

For reasons I don't know, the exact same thing now seems to be working fine for me.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

New cloud apps roundup - June 2021

Since our last roundup in April, Atlassian's Marketplace Partners have added over 100 new cloud apps to the Atlassian Marketplace to help your teams work more efficiently. Let’s take a quick look a...

349 views 5 10
Read article

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