Allow you to execute Groovy scripts directly.

You can access to this screen by clicking Script console in the Profields Administration Menu

 

Code source

You can select te origin of the script

  • INLINE: You can write the script in the textarea below named "Script code".

  • FILE: You can indicate the path of a script file that was placed in the JIRA server file system.

Execute the script

Only click the button 

If the execution ends successfully, a success message will show with the result of the script.

The code:

def foo = "Foo"
def var = "Var"
return foo + var

Shows:

FooCar

 

If there was an error while executing the script, an error message will show with the trace of the exception.

The code:

def foo = 5
def var = 0
return foo / var

Shows:

com.deiser.jira.profields.exception.GroovyException: java.lang.ArithmeticException: Division by zero
at com.deiser.jira.profields.action.script.ProfieldsScriptConsole.doExecute(ProfieldsScriptConsole.java:77)
at webwork.action.ActionSupport.execute(ActionSupport.java:165)
at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:88)
at webwork.interceptor.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:39)
at webwork.interceptor.NestedInterceptorChain.proceed(NestedInterceptorChain.java:31)
at webwork.interceptor.ChainedInterceptor.intercept(ChainedInterceptor.java:16)

...

Context Variables

You have several variables available in the script context:

 

  • logger : org.apache.log4j.Logger
  • configurationService : com.deiser.jira.profields.api.configuration.ConfigurationService
  • fieldService : com.deiser.jira.profields.api.field.FieldService
  • schemeService : com.deiser.jira.profields.api.scheme.SchemeService
  • jiraProjectManager : com.atlassian.jira.project.CachingProjectManager
  • jiraUserManager : com.atlassian.jira.user.util.UserManager
  • jiraAuthenticationContext : com.atlassian.jira.security.JiraAuthenticationContext
  • jiraApplicationProperties : com.atlassian.jira.config.properties.ApplicationProperties

 

import com.atlassian.jira.config.properties.APKeys
 
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Profields sort type: " + configurationService.sortType.name)
stringBuilder.append("<br/>Profields fields configured: " + String.valueOf(fieldService.get().size()))
stringBuilder.append("<br/>JIRA projects count: " + String.valueOf(jiraProjectManager.getProjectObjects().size()))
stringBuilder.append("<br/>JIRA logged in user: " + jiraAuthenticationContext.user.displayName)
stringBuilder.append("<br/>JIRA base url: " + jiraApplicationProperties.getDefaultBackedString(APKeys.JIRA_BASEURL))
return stringBuilder.toString()

Profields sort type: Global
Profields fields configured: 38
JIRA projects count: 10
JIRA logged in user: Tester
JIRA base url: http://testurl.com/jira