diff --git a/JiraPS/Public/Invoke-JiraIssueTransition.ps1 b/JiraPS/Public/Invoke-JiraIssueTransition.ps1 index e9f96d70..0e6f4845 100644 --- a/JiraPS/Public/Invoke-JiraIssueTransition.ps1 +++ b/JiraPS/Public/Invoke-JiraIssueTransition.ps1 @@ -41,6 +41,9 @@ function Invoke-JiraIssueTransition { [String] $Comment, + [String] + $TimeSpent, + [Parameter()] [System.Management.Automation.PSCredential] [System.Management.Automation.Credential()] @@ -174,7 +177,17 @@ function Invoke-JiraIssueTransition { Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Adding comment" $requestBody.update.comment += , @{ 'add' = @{ - 'body' = $Comment + 'body' = $Comment + } + } + } + + if($TimeSpent){ + Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Adding time spent" + $requestBody.update.worklog += , @{ + 'add' = @{ + 'timeSpent' = $TimeSpent + 'started' = (Get-Date -Format O) # Round-trip date/time pattern '2019-03-18T17:59:38.0788189+03:00' } } } diff --git a/Tests/Functions/Invoke-JiraIssueTransition.Unit.Tests.ps1 b/Tests/Functions/Invoke-JiraIssueTransition.Unit.Tests.ps1 index 5cc7c73c..a3b63eb0 100644 --- a/Tests/Functions/Invoke-JiraIssueTransition.Unit.Tests.ps1 +++ b/Tests/Functions/Invoke-JiraIssueTransition.Unit.Tests.ps1 @@ -163,6 +163,12 @@ Describe "Invoke-JiraIssueTransition" -Tag 'Unit' { Assert-MockCalled -CommandName Invoke-JiraMethod -ModuleName JiraPS -Times 1 -Scope It -ParameterFilter { $Method -eq 'Post' -and $URI -like "*/rest/api/latest/issue/$issueID/transitions" -and $Body -like '*body*test comment*' } } + It "Adds time spent if provided to the -TimeSpent parameter" { + { Invoke-JiraIssueTransition -Issue $issueKey -Transition 11 -TimeSpent "15m"} | Should Not Throw + + Assert-MockCalled -CommandName Invoke-JiraMethod -ModuleName JiraPS -Times 1 -Scope It -ParameterFilter { $Method -eq 'Post' -and $URI -like "*/rest/api/latest/issue/$issueID/transitions" -and $Body -like '*timeSpent*15m*' } + } + It "Returns the Issue object when -Passthru is provided" { { $result = Invoke-JiraIssueTransition -Issue $issueKey -Transition 11 -Passthru} | Should Not Throw $result = Invoke-JiraIssueTransition -Issue $issueKey -Transition 11 -Passthru diff --git a/docs/en-US/commands/Invoke-JiraIssueTransition.md b/docs/en-US/commands/Invoke-JiraIssueTransition.md index 6f2aa5d2..0aba5123 100644 --- a/docs/en-US/commands/Invoke-JiraIssueTransition.md +++ b/docs/en-US/commands/Invoke-JiraIssueTransition.md @@ -17,7 +17,7 @@ Performs an issue transition on a JIRA issue changing it's status ```powershell Invoke-JiraIssueTransition [-Issue] [-Transition] [[-Fields] ] - [[-Assignee] ] [[-Comment] ] [[-Credential] ] [-Passthru] [] + [[-Assignee] ] [[-Comment] ] [[-TimeSpent] ] [[-Credential] ] [-Passthru] [] ``` ## DESCRIPTION @@ -48,11 +48,11 @@ Invokes transition ID 11 on issue TEST-01. ### EXAMPLE 2 ```powershell -Invoke-JiraIssueTransition -Issue TEST-01 -Transition 11 -Comment 'Transition comment' +Invoke-JiraIssueTransition -Issue TEST-01 -Transition 11 -Comment 'Transition comment' -TimeSpent "15m" ``` -Invokes transition ID 11 on issue TEST-01 with a comment. -Requires the comment field to be configured visible for transition. +Invokes transition ID 11 on issue TEST-01 with a comment and time spent of 15m (can be any jira supported suffix, like 'h' for hours e.g.) +Requires the comment field to be configured visible for transition and time tracking enabled in JIRA preferences. ### EXAMPLE 3