GitHub Action
Jira Issue Updater
A GitHub action to update properties of an existing Jira issue.
- Only supports Jira Cloud.
- Requires Jira Login Action.
name: Jira Issue Updater
on: [..]
jobs:
update-jira-issue:
name: Update Jira issue
runs-on: ubuntu-latest
steps:
- name: Jira Login
uses: frieder/gha-jira-login@v1
env:
JIRA_BASE_URL: ${{ vars.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ vars.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
- name: Update Fields
id: updatefields
uses: frieder/jira-issue-updater@v1.1.0
with:
retries: 1
retryDelay: 10
timeout: 2000
failOnError: true
# either one of the following three config option formats of 'issue' is valid
issue: XYZ-123
issue: XYZ-1,XYZ-2,XYZ-3
issue: |
XYZ-1
XYZ-2
XYZ-3
summary: Some fancy title
description: Plaintext only
assignee: 123456:12345678-abcd-abcd-abcd-1234567890ab
priority: Lowest
duedate: 2023-02-01
resolution: Won't Do
components: |
= component1
= component2
+ component3
- component2
fixversions: |
= 1.0
= 1.1
+ 2.0
- 1.1
labels: |
= foo
= foo2
= bar2
+ bar
- foo2
- bar2
customfields: |
10050: some value
10051: 2023-01-01
10052: https://github.com/marketplace?type=action
customfieldsJson: |
10057: {"content":[{"content":[{"type":"text","text":"Content for the TextArea custom field"}],"type":"paragraph"}],"type":"doc","version":1}
10058: ["value1", "value2]
# this action will only be reached when failOnError was set to false in the previous step
- name: Print Outputs
run: |
echo "HAS ERRORS: ${{ steps.updatefields.outputs.hasErrors }}"
echo "IDs SUCCESS: ${{ steps.updatefields.outputs.successful }}"
echo "IDs ERROR: ${{ steps.updatefields.outputs.failed }}"
Required | no |
Default | 1 |
This option allows to define a number of retries when the HTTP call to the Jira REST API fails (e.g. due to connectivity issues). By default, the action will attempt one retry and after that report the request as failed.
Required | no |
Default | 10 |
In case the retries
option is > 0, this option defines the time (in seconds) the action will wait in
between the requests.
Required | no |
Default | 2000 |
The time (in milliseconds) the action will wait for a request to finish. If the request does not finish in time it will be considered failed.
Required | no |
Default | true |
When set to true (default) the action will report back as failed whenever at least one issue could not be updated. When set to false it means the action will never fail (unless an exception occurs outside the requests, e.g. when reading login data, parsing inputs etc.). Also check the documentation about outputs of this action.
Required | yes |
Default |
The ID(s) of the Jira ticket (e.g. XYZ-123). This option allows to define one or many issue IDs at the same time. For multiple IDs it also allows to define those in two different formats.
- A comma-separated list of issue IDs
- A line-separated list pf issue IDs
This is the only option that must be provided explicitly. All the following options are optional with the requirement that at least one of them must be provided.
Required | no |
Default |
Updates the summary (title) of the ticket.
The option is ignored when blank.
Required | no |
Default |
Updates the description of the ticket.
The option is ignored when blank.
This option only allows for a simple plaintext to be set.
Required | no |
Default |
Updates the assignee of the ticket. For this the ID of the respective user is required.
To get the ID of yourself just open the profile page and check the URL for the ID. Another possibility is to use the Jira REST API.
The option is ignored when blank. To remove the assignee set the value to REMOVE
.
Required | no |
Default |
Updates the priority of the ticket. Possible values are the actual names of the priorities as defined in
https://ACCOUNT.atlassian.net/secure/admin/ViewPriorities.jspa
. By default, these names are:
Lowest
Low
Medium
High
Highest
The option is ignored when blank.
Required | no |
Default |
Updates the due date of the ticket. The format must be in ISO 8601 format - yyyy-MM-dd
.
The option is ignored when blank. To remove the due date set the value to REMOVE
.
Required | no |
Default |
Updates the resolution of the ticket.
The option is ignored when blank.
Required | no |
Default |
Make sure your project template supports components or this option will not work. Also make sure the components exist in Jira (check your project's settings) before using them in this action.
Allows to set|add|remove
components to a Jira ticket. A set of components must be provided with
one entry per line. Depending on the prefix different actions are performed.
=
When a line is prefixed with this character it will be treated like aSET
action.+
When a line is prefixed with this character it will be treated like anADD
action.-
When a line is prefixed with this character it will be treated like aREMOVE
action.no prefix
- When a line does not have any prefix as described above it will be ignored.
In order for this to work all entries will first be grouped and assigned to one of the three groups.
Afterwards it will create a body payload that includes the SET
group first followed by the ADD
group and then the REMOVE
group. Check the Jira REST API
for more information.
When a
SET
group is available it will basically replace whatever was available before. TheADD
group will then add additional entries on top of the new values from theSET
group. TheREMOVE
group will be applied last and will remove entries that were added by the two other groups. The usual use-case however is to either useSET
or a combination ofADD
andREMOVE
groups. In most cases it does not make sense to mix all three groups in one step.
The option is ignored when blank.
Required | no |
Default |
Make sure your project template supports versions or this option will not work. Also make sure the versions exist in Jira (check your project's releases) before using them in this action.
Allows to set|add|remove
fix versions for a Jira ticket. A set of versions must be provided with
one entry per line. Depending on the prefix different actions are performed.
=
When a line is prefixed with this character it will be treated like aSET
action.+
When a line is prefixed with this character it will be treated like anADD
action.-
When a line is prefixed with this character it will be treated like aREMOVE
action.no prefix
- When a line does not have any prefix as described above it will be ignored.
In order for this to work all entries will first be grouped and assigned to one of the three groups.
Afterwards it will create a body payload that includes the SET
group first followed by the ADD
group and then the REMOVE
group. Check the Jira REST API
for more information.
When a
SET
group is available it will basically replace whatever was available before. TheADD
group will then add additional entries on top of the new values. TheREMOVE
group will then remove entries that were added by the two other groups. The usual use-case however is to either useSET
or a combination ofADD
andREMOVE
groups. It does not make sense to mix all three groups in one step.
The option is ignored when blank.
Required | no |
Default |
Allows to set|add|remove
labels to a Jira ticket. A set of labels must be provided with
one entry per line. Depending on the prefix different actions are performed.
=
When a line is prefixed with this character it will be treated like aSET
action.+
When a line is prefixed with this character it will be treated like anADD
action.-
When a line is prefixed with this character it will be treated like aREMOVE
action.no prefix
- When a line does not have any prefix as described above it will be ignored.
In order for this to work all entries will first be grouped and assigned to one of the three groups.
Afterwards it will create a body payload that includes the SET
group first followed by the ADD
group and then the REMOVE
group. Check the Jira REST API
for more information.
When a
SET
group is available it will basically replace whatever was available before. TheADD
group will then add additional entries on top of the new values. TheREMOVE
group will then remove entries that were added by the two other groups. The usual use-case however is to either useSET
or a combination ofADD
andREMOVE
groups. It does not make sense to mix all three groups in one step.
When a value for a non-existing component is used the Jira REST API will create such a component.
The option is ignored when blank.
Required | no |
Default |
Updates the value of custom fields in the Jira ticket. It expects a set of IDs for the custom fields along
with their associated value, separated by a colon (:
). One entry per line.
The value of a custom field can contain colons (
:
) as only the first occurance of a colon per line is interpreted as a delimiter.
The option is ignored when blank.
Required | no |
Default |
Updates the value of custom fields in the Jira ticket. It expects a set of IDs for the custom fields along
with their associated JSON encoded value, separated by a colon (:
). One entry per line.
JSON encoded value is needed when you want to se multi-value custom fields, or more complex ones that require Atlassian Document Format.
The value of a custom field can contain colons (
:
) as only the first occurrence of a colon per line is interpreted as a delimiter.
The option is ignored when blank.
This action provides some information via outputs for post-processing. Following is an overview of the keys registered with the action's output.
hasErrors
- A boolean value indicating whether there are issues that have not been updated successfully. This is useful when thefailOnError
option is set tofalse
and one still wants to check if there have been failed update attempts.successful
- A list of IDs of issues that have successfully been updated. The format is the same as used with theissues
option (either comma or line separated).failed
- A list of IDs of issues that failed to get updated. This may be useful to add comments to the tickets in question or to report those tickets to a Slack or MSTeams channel. The format is again the same as with theissues
option.
This action can be tested during development with the use of https://github.com/nektos/act.
Please adapt the values accordingly both in the workflow file and in the CLI command.
act -W .github/workflows/pr.yml \
-j check \
-s JIRA_URL=*** \
-s JIRA_EMAIL=*** \
-s JIRA_TOKEN=***
#--var JIRA_ISSUES=WEB-123