Skip to main content

Jira Comment

Jira is a software development tool used for issue tracking, project management, and agile software development. It allows users to plan, track, and release software projects. Jira's core functionality includes the ability to create and assign tasks, track progress and status, and collaborate with team members.

By adding Appcircle's Jira Comment component to your workflow, you can add comments or change their status according to your workflow.

Prerequisites

There is no mandatory sequence for the use of this component. It depends on your business decision which step to use before or after in your workflow.

caution

Please note that once the Jira Comment has run successfully, the status of the relevant article in your Jira account will be changed. If the build fails in Appcircle, an incorrect status may appear in your Jira account. Make sure you use it in the correct order in Workflow.

danger

To ensure that the Jira Comment step runs even if your workflow fails, please enable the Always run this step even if the previous steps fail switch.

Configuration of Jira Comment

To add a comment, the issue ID must be supplied to the component. We need to get this issue ID dynamically so that our workflow can work for multiple branches. Appcircle components use environment variables to pass the state. We can add a step just before the Jira Comment to prepare the necessary environment variables.

For example, you're working on a feature branch called feature/jiraissue-1. You may use the below Ruby script to get jiraissue-1 from the branch name and use this information with the Jira Comment. Please see the Custom Script documentation for this implementation.

branch = ENV['AC_GIT_BRANCH']
feature_name = branch.split('/')[1].upcase
puts feature_name

# Write Environment Variable
open(ENV['AC_ENV_FILE_PATH'], 'a') { |f|
f.puts "AC_JIRA_ISSUE=#{feature_name}"
}

Jira REST API Version Reference

Jira Comment input types depend on the Jira REST API version. Therefore, you can select the appropriate Jira REST API version from the component version selection list. Here's how:

  • For Jira REST API version 2: This version can be used by both Jira On-Prem and Jira Cloud users. Choose 2.*.* from the selection list.
  • For Jira REST API version 3: This version can only be used by Jira Cloud users. Choose 3.*.* from the selection list.

Changing Template

Appcircle provides a default template that adds commit id, branch name, time in UTC, and a couple of environment variables. The structure of the Jira comment template depends on the version of the Jira REST API you're utilizing.

If you're utilizing API version 2, commenting is limited to string type only. On the other hand, for Jira API version 3, you have the flexibility to send comments in any format using the Atlassian Document Format (ADF). To create custom comments for version 3, you can leverage tools like the ADF Builder.

Input Variables

There are some necessary parameters for this stepper to work properly. These parameters are given in the table below with their descriptions.

danger

Confidential information should be entered as a secret environment variable. Also, ensure that the environment variable group is selected in the configuration.

info

The required inputs for authorization vary based on the type of Jira instance (On-Prem or Cloud). Below is a summary of the required inputs:

For Jira On-Prem Users:

  • AC_JIRA_EMAIL: Not required
  • AC_JIRA_TOKEN: Not required
  • AC_JIRA_PAT: Required

For Jira Cloud Users:

  • AC_JIRA_EMAIL: Required
  • AC_JIRA_TOKEN: Required
  • AC_JIRA_PAT: Not required
Variable NameDescriptionStatus
$AC_JIRA_HOSTYour Jira subdomain. For example: mysubdomain.atlassian.netRequired
$AC_JIRA_EMAILThe email associated with your Jira account. This field is required for using API tokens instead of PAT.Optional
$AC_JIRA_TOKENUser's API Token. If this value is fill, the Jira e-mail field must be filled. Only Jira Cloud users can use API Token. You can create token from hereOptional
$AC_JIRA_PATSpecify the Personal Access Token for Jira authentication. Only Jira On-Prem users can use PAT.Optional
$AC_JIRA_ISSUEThe ID or key of the issue. Refer to the documentation for instructions on extracting this information from branch names or commit messages.Required
$AC_JIRA_FAIL_TRANSITIONTransition ID or name for the failed step. Optionally change the status of your issue if the previous state fails. Ensure that the Always run this step even if the previous steps fail switch is enabled for this feature to work.Optional
$AC_JIRA_SUCCESS_TRANSITIONTransition ID or name for the successful step. Optionally change the status of your issue if the previous state succeeds.Optional
$AC_JIRA_TEMPLATE_V2The comment template used to post a comment if Jira REST API Version 2 is selected. Variables prefixed with $ will be replaced during the build process. Refer to this header to modify the template.Required
$AC_JIRA_TEMPLATE_V3The comment template used to post a comment if Jira REST API Version 3 is selected. Variables prefixed with $ will be replaced during the build process. Refer to this header to modify the template.Required

To access the source code of this component, please use the following link:

Preview of GitHub - appcircleio/appcircle-jira-component