Services
A service is a class that runs periodically within Jira. Since a service runs inside Jira, it has the ability to use all of the Jira API — and, as it is written in Java, it can use any Java libraries.
Services are useful because they enable you to integrate with external systems by pulling data into Jira periodically. Jira comes with a number of pre-written services, and custom services can be written and plugged in at runtime.
Writing a new service?
If you are not extending a built-in Jira service, you should strongly consider writing your new service using the SAL API. Please see our Scheduling Events via SAL Tutorial for more information.
For all of the following procedures, you must be logged in as a user with the Jira system administrator global permissions.
Registering a service
For custom-written services, make sure your service class is in the classpath where Jira can see it — the best locations are usually the <jira-application-dir>/WEB-INF/classes
or <jira-application-dir>/WEB-INF/lib
subdirectories within of your Jira application installation directory (as JAR files).
To register a service:
- In the upper-right corner of the screen, select Administration > System.
- Under Advanced (the left-side panel), select Services to open a page showing all the configured services.
- In the Add Service form at the bottom of the page, complete the following fields:
- Name — a descriptive name for this service.
Class — the fully-qualified class name of your service. This is likely to have the form
com.atlassian.jira.service.services.
type.Type
Service
See Sample services for provided service class names.To use one of Jira's built-in service classes, first click the Built-in Services link to expand the list of service classes and then click the name of the specific class in the list. The fully-qualified class name of the built-in service will be added to the Class field.
- Delay — the delay (in minutes) between service runs.
For example, to add a debugging service, click the Built-in Services link followed by the Debugging Service link.
After completing the fields on the Add Service form, click the Add Service button. This opens the Edit Service page, where you can configure your new service's options.
Your service's options will vary depending on the type (i.e. class) of service you chose.
- After completing the remaining options on the Edit Service page, click the Update button to save your new service's options.
Editing service properties
- In the upper-right corner of the screen, select Administration > System.
- Under Advanced (the left-side panel), select Services to open a page showing all the configured services.
- Select the Edit link associated with the service whose properties you wish to edit.
For example, to change the interval at which email is sent from Jira, edit the Mail Queue Service and change the Delay from the default value of 1 minute.
Removing a service
- In the upper-right corner of the screen, select Administration > System.
- Under Advanced (the left-side panel), select Services to open a page showing all the configured services.
- Select the Delete link associated with the service you wish to remove.
Built-in services
Jira has some useful services out of the box, which may be used as-is or modified for use in your own environment. The source code for all built-in services is available and should give you a good overview of how simple it is to write your own services. All built-in services are included with Jira and need only be configured to be used.
Export service
The Export Service is useful for periodically backing up Jira. It exports all data from Jira every time it is run, into a directory supplied as a parameter. The export files are timestamped, thus the service can act as a backup system.
To test this service, add a service with the class com.atlassian.jira.service.services.export.ExportService. Jira sets up an ExportService in new Jira installations (once the setup wizard has been completed). Hence, you may find you already have one.
You can find this class within the following directory of an expanded Jira source archive (which can be downloaded by Jira customers from https://my.atlassian.com):<source-installation-directory>/jira-project/jira-components/jira-core/src/main/java/com/atlassian/jira/service/services/export
Mail handler services
Jira mail handler services are not configurable through Jira's Services page (with the exception of being able to be removed). For more information about configuring a mail handler in Jira, including the creation of custom mail handlers, please refer to Creating issues and comments from email.
Custom services
If you are a Jira developer who wishes to write your own Jira service, please note that Jira Service classes must all extend com.atlassian.jira.service.JiraService. Most do so by extending com.atlassian.jira.service.AbstractService or some more specialized subclass.