Adding a Jira Integration
To send messages to Jira, you must first add a Jira Integration to Pipelines. The Jira integration securely holds your access credentials in Pipelines' encrypted vault, so that this information is not viewable in the text of your Pipelines DSL file.
To add a Jira integration, follow the procedures in Managing Pipelines Integrations.
For example, to add a Jira integration called
myJira, you might enter the following:
The User Name and Token fields provide the necessary credentials to authenticate access from Pipelines:
- The user account represented by User Name must have permissions to access the Jira project where issues are to be created.
- When integrating with Jira Cloud, you must provide the Jira API token for the Jira user account in the Token field.
- When integrating with Jira Server, you must provide the user account password in the Token field (Jira Server does not support API tokens).
Creating a Jira Issue
To create a new Jira issue (ticket) from step in a pipeline:
- Declare the Jira integration in the
integrationssection of the step.
- Use the send_notification utiliity function to notify the Jira integration to create an issue ticket.
You will typically send the notification to Jira in an
onFailure portion of the step's
The project-id must specify a key for a project that has already been created in Jira. If Jira receives a request to create a ticket for a project that doesn't exist, Jira will ignore the request.
Using Environment Variables
If your pipeline will have multiple failure points to create a Jira issue, you might choose to define common values for options such as project-id and type in environment variables for those options. The
send_notification utility function for a Jira integration will automatically use any of these environment variables when they are defined:
|--project-id||the project key of the project to associate the new issue with|
the issue type for the new issue (e.g., "Bug", "Task", etc.).
a string for the new issue's Summary field (it's title)
a string for the new issue's Description field
a path to a file to attach to the issue
You can define any of these environment variables in the pipeline's
configuration block using the
environmentVariables tag, so that they will be available to all steps in the pipeline. You can also, if needed, specify
environmentVariables in the step's
configuration block to override their value for the span of that step's execution.
The following example pipeline demonstrates the use of the
send_notification utility function to create a Jira issue (ticket).
The example Pipelines DSL performs the following:
- Sets environment variables for the project-id and type options
- Performs a MvnBuild native step, which produces a log file.
- On failure, uses the
send_notificationutility function to create the JIra ticket. The command line:
- Relies on the environment variables for the project-id and type options
- Attaches the log file produced by Maven to the Jira issue
- Specifies the summary and description options using standard environment variables