Automatic Imports and Extension Methods
This page provides technical information on automatic imports and extension methods.
Automatic imports
For convenience, HAPI classes such as
Issues
, Users
, and Projects
are automatically imported into all scripts compiled within ScriptRunner, so an explicit import is not required.
If you import another class called Issues
, this results in a conflict. To avoid conflicts, HAPI classes won't automatically import if there is an existing import for a class with the same name in a script.
For cases where you have a script that contains a conflicting import, you can access HAPI via the Hapi
automatic import. This automatic import is unlikely to conflict with other classes. For example:
groovyHapi.issues.create('ABC', 'Task') { summary = 'Hello world' }
Extension methods
Extension methods are methods that ScriptRunner adds to classes that are not part of its own API, for instance the Atlassian Jira API. In the following example, delete()
is an extension method that is added by ScriptRunner.
groovydef issue = Issues.getByKey('ABC-1') issue.delete()
Other examples of extension methods include issue.update()
, user.delete()
and group.add()
.
Related content
- Our Javadocs provide details of all available extension methods.