From 6658dc0b1b9b2fb094f2e1a7a28441dd4c8fae41 Mon Sep 17 00:00:00 2001 From: AtlassianPS Automated User Date: Mon, 18 Mar 2019 18:35:56 +0300 Subject: [PATCH 1/4] ability to add time spent during issue transition #314 --- JiraPS/Public/Invoke-JiraIssueTransition.ps1 | 15 ++++++++++++++- .../Invoke-JiraIssueTransition.Unit.Tests.ps1 | 6 ++++++ docs/en-US/commands/Invoke-JiraIssueTransition.md | 8 ++++---- 3 files changed, 24 insertions(+), 5 deletions(-) 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 From 8e1bdafa9e9e777a6cd96c63efc6d7db05da113e Mon Sep 17 00:00:00 2001 From: AtlassianPS Automated User Date: Mon, 18 Mar 2019 18:51:53 +0300 Subject: [PATCH 2/4] Revert "ability to add time spent during issue transition #314" This reverts commit 6658dc0b1b9b2fb094f2e1a7a28441dd4c8fae41. --- JiraPS/Public/Invoke-JiraIssueTransition.ps1 | 15 +-------------- .../Invoke-JiraIssueTransition.Unit.Tests.ps1 | 6 ------ docs/en-US/commands/Invoke-JiraIssueTransition.md | 8 ++++---- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/JiraPS/Public/Invoke-JiraIssueTransition.ps1 b/JiraPS/Public/Invoke-JiraIssueTransition.ps1 index 0e6f4845..e9f96d70 100644 --- a/JiraPS/Public/Invoke-JiraIssueTransition.ps1 +++ b/JiraPS/Public/Invoke-JiraIssueTransition.ps1 @@ -41,9 +41,6 @@ function Invoke-JiraIssueTransition { [String] $Comment, - [String] - $TimeSpent, - [Parameter()] [System.Management.Automation.PSCredential] [System.Management.Automation.Credential()] @@ -177,17 +174,7 @@ function Invoke-JiraIssueTransition { Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Adding comment" $requestBody.update.comment += , @{ 'add' = @{ - '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' + 'body' = $Comment } } } diff --git a/Tests/Functions/Invoke-JiraIssueTransition.Unit.Tests.ps1 b/Tests/Functions/Invoke-JiraIssueTransition.Unit.Tests.ps1 index a3b63eb0..5cc7c73c 100644 --- a/Tests/Functions/Invoke-JiraIssueTransition.Unit.Tests.ps1 +++ b/Tests/Functions/Invoke-JiraIssueTransition.Unit.Tests.ps1 @@ -163,12 +163,6 @@ 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 0aba5123..6f2aa5d2 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] ] [[-TimeSpent] ] [[-Credential] ] [-Passthru] [] + [[-Assignee] ] [[-Comment] ] [[-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' -TimeSpent "15m" +Invoke-JiraIssueTransition -Issue TEST-01 -Transition 11 -Comment 'Transition comment' ``` -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. +Invokes transition ID 11 on issue TEST-01 with a comment. +Requires the comment field to be configured visible for transition. ### EXAMPLE 3 From 086b3616f6f7d0fe1a77e1bad3c4a0e0f2682a7a Mon Sep 17 00:00:00 2001 From: AtlassianPS Automated User Date: Mon, 18 Mar 2019 21:27:18 +0300 Subject: [PATCH 3/4] adding possibility to worklog on issue during transition --- JiraPS/Public/Invoke-JiraIssueTransition.ps1 | 13 ++++++++ .../Invoke-JiraIssueTransition.Unit.Tests.ps1 | 6 ++++ .../commands/Invoke-JiraIssueTransition.md | 30 +++++++++++++++---- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/JiraPS/Public/Invoke-JiraIssueTransition.ps1 b/JiraPS/Public/Invoke-JiraIssueTransition.ps1 index e9f96d70..ca83407b 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..561beeb5 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 From 028096093303ddcc111c9cd5cbb31d2ccc91fcb3 Mon Sep 17 00:00:00 2001 From: AtlassianPS Automated User Date: Wed, 20 Mar 2019 10:59:42 +0300 Subject: [PATCH 4/4] fixed typo in documentation url brackets --- JiraPS/Public/Invoke-JiraIssueTransition.ps1 | 2 +- docs/en-US/commands/Invoke-JiraIssueTransition.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/JiraPS/Public/Invoke-JiraIssueTransition.ps1 b/JiraPS/Public/Invoke-JiraIssueTransition.ps1 index ca83407b..dafa9f42 100644 --- a/JiraPS/Public/Invoke-JiraIssueTransition.ps1 +++ b/JiraPS/Public/Invoke-JiraIssueTransition.ps1 @@ -187,7 +187,7 @@ function Invoke-JiraIssueTransition { $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 + '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 } } } diff --git a/docs/en-US/commands/Invoke-JiraIssueTransition.md b/docs/en-US/commands/Invoke-JiraIssueTransition.md index 561beeb5..d3aaa02c 100644 --- a/docs/en-US/commands/Invoke-JiraIssueTransition.md +++ b/docs/en-US/commands/Invoke-JiraIssueTransition.md @@ -230,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 ( +For more information, see about_CommonParameters (). ## INPUTS