For support issues please visit https://jira.deiser.com/support

What's next? Check our backlog and vote the ideas here: https://trello.com/b/kxrEGuIW/profields-public-backlog

Page tree
Skip to end of metadata
Go to start of metadata

 

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:

Success

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:

Error

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

 

Example
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()

Success

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

 

 

 

On this page

 

 

  • No labels