diff --git a/JiraPS/Public/Invoke-JiraIssueTransition.ps1 b/JiraPS/Public/Invoke-JiraIssueTransition.ps1 index 85199183..8578f397 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()] @@ -179,6 +182,16 @@ function Invoke-JiraIssueTransition { } } + if ($TimeSpent) { + Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Adding time spent" + $requestBody.update.worklog += , @{ + 'add' = @{ + 'timeSpent' = $TimeSpent + 'started' = (Get-Date -f "yyyy-MM-ddThh:mm:ss.fffzz00") #should be ISO 8601: YYYY-MM-DDThh:mm:ss.sTZD, format "o" not working, cause zzz contains semicolon + } + } + } + $parameter = @{ URI = "{0}/transitions" -f $issueObj.RestURL Method = "POST" diff --git a/Tests/Functions/Invoke-JiraIssueTransition.Unit.Tests.ps1 b/Tests/Functions/Invoke-JiraIssueTransition.Unit.Tests.ps1 index 5cc7c73c..bd78f0cf 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 a worklog if provide 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..d3aaa02c 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 -TimeSpent "15m" 'Transition comment' ``` -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 worklog of 15m (you can use jira suffixes, e.g. 8h) +Requires the comment field to be configured visible for transition and Time Tracking to be enabled in JIRA instance ### EXAMPLE 3 @@ -176,6 +176,24 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -TimeSpent + +Time Spent worklog should be added to issue + +Time Tracking should be enabled on JIRA instance. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 6 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Credential Credentials to use to connect to JIRA. @@ -187,7 +205,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 6 +Position: 7 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -212,7 +230,7 @@ Accept wildcard characters: False ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. -For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +For more information, see about_CommonParameters (). ## INPUTS