Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Groovy Class Multiple Instances without Duplicating

David Harkins
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
September 28, 2023

I'm have some issue with a ScriptRunner / Groovy script.

Improving our Incident and Problem process,

Have a defined class with a constructor that takes an issue and populates a variable.

I can create one instance of the class and everything works as expected.

The moment i create a 2nd instance on the same class, the 1st one i created returns the same values as the newly created class.

 

import ASI.Issue_Client
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Level
import org.apache.log4j.Logger
def logOutput = Logger.getLogger('CONSOLE')
logOutput.setLevel(Level.DEBUG)
logOutput.info('Script Starting')
def issueManager = ComponentAccessor.getIssueManager()

Issue_Client activeIncidentIssue = new Issue_Client ( issueManager.getIssueObject( 'issue-94002' ) )

logOutput.debug('activeIncidentIssue: ' + activeIncidentIssue.WorkingIssue.key)
logOutput.debug('----------')

Issue_Client activeProblemIssue = new Issue_Client (issueManager.getIssueObject( 'issue-94123' ))

logOutput.debug('activeIncidentIssue: ' + activeIncidentIssue.WorkingIssue.key)
logOutput.debug('activeProblemIssue: ' + activeProblemIssue.WorkingIssue.key)

I get the following log output:

 

2023-09-28 13:11:25,933 INFO [CONSOLE]: Script Starting

2023-09-28 13:11:25,949 DEBUG [CONSOLE]: activeIncidentIssue: issue-94002

2023-09-28 13:11:25,949 DEBUG [CONSOLE]: ----------

2023-09-28 13:11:25,949 DEBUG [CONSOLE]: activeIncidentIssue: issue-94123

2023-09-28 13:11:25,949 DEBUG [CONSOLE]: activeProblemIssue: issue-94123

 

The activeIncidentIssue should remain the same value

 

The key values from my class definition are:

public class Issue_Base {
    public static Issue WorkingIssue
    public Issue_Base (Issue issue) {
        WorkingIssue = issue
    }
}

 

2 answers

1 vote
Bharath Kumar Kappala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
October 10, 2018

Just go to project setting> Screens and add the "Time Tracking" to the bug Screen scheme and you will see time tracking section for Bug issue type as well.

Bharath Kumar Kappala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
October 10, 2018

Here is the screen shotimage.png

0 votes
Gerald Britton
October 16, 2018

That sounds like it should work.  Unfortunately in our company this is locked down and unavailable. Even site admins are not allowed to enable time tracking for bugs.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events