Using GString Templates

ScriptRunner allows you to write Groovy scripts with dynamically generated text using GString TemplatesYou can add dynamic text in a template using the ${expression} syntax. All editors supporting GString Templates in ScriptRunner have Code Insight, allowing you to utilize code completions, parameter hints, and Javadoc lookup.

Below we show a simple example of how you can use GString Templates in ScriptRunner

For example, if you want to create a Send Custom Email listener, you can write the Email template and Subject template using GString Templates.

The following example is for a custom email triggering on a fork repository event. 

  1. Enter the following into the Subject template field:

    Fork ${event.repository.project.key}/${event.repository.name} has just been created
  2. Enter the following into the Email template field:

    User ${event.user.displayName} has forked the repository ${event.repository.origin.project.key}/${event.repository.origin.name}. The name of the new repository is: ${event.repository.project.key}/${event.repository.name}