This page explains the mechanics for updating a Jira issue.
Jira issues can be updated in 3 different ways:
Editing issues is done with the Set-JiraIssue
function.
# Assign an issue
Set-JiraIssue TEST-1 -Assignee 'bob'
# Get the issue's existing summary and add a tag
$issue = Get-JiraIssue TEST-1
$issue | Set-JiraIssue -Summary "$($issue.Summary) (Modified by PowerShell)"
# Change the issue's summary and add a comment for that change
$issue | Set-JiraIssue -Summary "New Summary" -AddComment "Changed summary for testing"
If the field you want to change does not have a named parameter, Set-JiraIssue
also supports changing arbitrary fields using the -Fields
parameter.
For more information on this parameter, see the custom_fields page.
You can set labels on an issue using Set-JiraIssue
’s -Label
parameter.
Using this function will overwrite any existing labels on the issue.
-SkipNotification
parameter tells JIRA to not update users abouth the change. Default behaviour is always send notifications.
Get-JiraIssue TEST-1 | Set-JiraIssue -Label 'Funny','Testing' -SkipNotification
For better control over labels, use Set-JiraIssueLabel
.
This provides more granular control over the labels in an issue using four parameters:
The -Add
and -Remove
parameters can be used together; -Set
and -Clear
must be used individually.
$issue = Get-JiraIssue TEST-1
# Overwrite all labels with these two
$issue | Set-JiraIssueLabel -Set 'Funny','Test'
# Add another label and remove the Funny label - after this, the
# issue will have 'Test' and 'Serious'
$issue | Set-JiraIssueLabel -Add 'Serious' -Remove 'Funny'
# Remove ALL the labels!
$issue | Set-JiraIssueLabel -Clear
Add-JiraIssueComment
is your friend here.
Add-JiraIssueComment -Issue TEST-1 -Comment "Test comment from PowerShell"
You can also use Format-Jira
to convert a PowerShell object into a Jira table.
$commentText = Get-Process powershell | Format-Jira
Get-JiraIssue TEST-1 | Add-JiraIssueComment "Current PowerShell processes:\n$commentText"
Like other
Format-*
commands,Format-Jira
is a destructive operation for data in the pipeline. Remember to “filter left, format right!”
Comments can also be added while changing other fields of issues, e.g. the assignee:
Set-JiraIssue -Issue TEST-1 -Assignee "John" -Addcomment "Dear mr. Doe, please review this issue.Thx"
Closing an issue, reopening an issue, or changing an issue to a pending state are all examples of what Jira calls “issue transitions.” The transitions an issue can perform depend on its current status and the Jira workflow set up for its project.
First, check the transitions an issue can currently perform:
(Get-JiraIssue TEST-1).Transition
Once you have a list of transitions, use Invoke-JiraIssueTransition
with the ID of the transition to perform:
Get-JiraIssue TEST-1 | Invoke-JiraIssueTransition -Transition 11
For more information on configuring transitions in JIRA, see Atlassian’s article on JIRA Workflows.