Skip to content

Commit a0e29a6

Browse files
authored
Merge pull request #326 from AtlassianPS/release/v2.9
Release v2.9
2 parents 8aa72ef + db256de commit a0e29a6

22 files changed

+717
-79
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Change Log
22

3+
## [2.9] - 2018-12-12
4+
5+
### Added
6+
7+
- Parameter for selecting what fields to return the the issue's payload (#300, [@tuxgoose])
8+
- Added pipeline support to `New-JiraIssue` (#312, [@ctolan])
9+
- Added parameter to avoid notifying user when running `Set-JiraIssue` (#315, [@alexsuslin])
10+
- Improved documentation to demonstrate how to authenticate with 2FA (#313, [@lipkau])
11+
- Added function to download attachments from issue: `Get-JiraIssueAttachmentFile` (#323, [@lipkau])
12+
13+
### Changed
14+
15+
- Fixed the way a user is resolved in `Remove-JiraGroupMember` (#301, [@lipkau])
16+
- Improved the resolving of server responses with an error (#303, [@lipkau])
17+
- Fixed payload of `New-JiraFilter` (#304, [@lipkau])
18+
- Fixed paging when server responds with only 1 result (#307, [@lipkau])
19+
- Fixed `Set-JiraIssue` to allow to unassigned an issue (#309, [@lipkau])
20+
- Changed CI/CD pipeline from AppVeyor to Azure DevOps (#317, [@lipkau])
21+
- Fixed missing properties on `Get-JiraUser` (#321, [@lipkau])
22+
- Fixed `-DateStarted` on `Add-JiraIssueWorklog` (#324, [@lipkau])
23+
24+
325
## [2.8] - 2018-06-28
426

527
More detailed description about the changes can be found on [Our Website](https://atlassianps.org/article/announcement/JiraPS-v2.8.html).
@@ -279,6 +301,7 @@ which is in turn inspired by the [Vagrant](https://github.com/mitchellh/vagrant/
279301
[@beaudryj]: https://github.com/beaudryj
280302
[@brianbunke]: https://github.com/brianbunke
281303
[@Clijsters]: https://github.com/Clijsters
304+
[@ctolan]: https://github.com/ctolan
282305
[@colhal]: https://github.com/colhal
283306
[@Dejulia489]: https://github.com/Dejulia489
284307
[@ebekker]: https://github.com/ebekker
@@ -290,4 +313,5 @@ which is in turn inspired by the [Vagrant](https://github.com/mitchellh/vagrant/
290313
[@lukhase]: https://github.com/lukhase
291314
[@padgers]: https://github.com/padgers
292315
[@ThePSAdmin]: https://github.com/ThePSAdmin
316+
[@tuxgoose]: https://github.com/tuxgoose
293317
[@WindowsAdmin92]: https://github.com/WindowsAdmin92

JiraPS/JiraPS.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
RootModule = 'JiraPS.psm1'
55

66
# Version number of this module.
7-
ModuleVersion = '2.8'
7+
ModuleVersion = '2.9'
88

99
# Supported PSEditions
1010
# CompatiblePSEditions = @()

JiraPS/Public/Add-JiraIssueWorklog.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ function Add-JiraIssueWorklog {
7373
Write-Error @errorMessage
7474
}
7575

76+
# Harmonize DateStarted:
77+
# `Get-Date -Date "01.01.2000"` does not return the local timezone
78+
# which is required by the API
79+
$DateStarted = [DateTime]::new($DateStarted.Ticks, 'Local')
80+
7681
$requestBody = @{
7782
'comment' = $Comment
7883
# We need to fix the date with a RegEx replace because the API does not like:

JiraPS/Public/Get-JiraIssue.ps1

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ function Get-JiraIssue {
6565
[Object]
6666
$Filter,
6767

68+
[Parameter()]
69+
[ValidateNotNullOrEmpty()]
70+
[String[]]
71+
$Fields = "*all",
72+
6873
[Parameter( ParameterSetName = 'ByJQL' )]
6974
[Parameter( ParameterSetName = 'ByFilter' )]
7075
[UInt32]
@@ -91,8 +96,10 @@ function Get-JiraIssue {
9196

9297
$server = Get-JiraConfigServer -ErrorAction Stop
9398

94-
$resourceURi = "$server/rest/api/latest/issue/{0}?expand=transitions"
9599
$searchURi = "$server/rest/api/latest/search"
100+
$resourceURi = "$server/rest/api/latest/issue/{0}"
101+
102+
[String]$Fields = $Fields -join ","
96103
}
97104

98105
process {
@@ -105,11 +112,18 @@ function Get-JiraIssue {
105112
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Processing [$_key]"
106113
Write-Debug "[$($MyInvocation.MyCommand.Name)] Processing `$_key [$_key]"
107114

115+
$getParameter = @{ expand = "transitions" }
116+
if ($Fields) {
117+
$getParameter["fields"] = $Fields
118+
}
119+
108120
$parameter = @{
109-
URI = $resourceURi -f $_key
110-
Method = "GET"
111-
Credential = $Credential
121+
URI = $resourceURi -f $_key
122+
Method = "GET"
123+
GetParameter = $getParameter
124+
Credential = $Credential
112125
}
126+
113127
Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
114128
$result = Invoke-JiraMethod @parameter
115129

@@ -122,7 +136,7 @@ function Get-JiraIssue {
122136
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Processing [$_issue]"
123137
Write-Debug "[$($MyInvocation.MyCommand.Name)] Processing `$_issue [$_issue]"
124138

125-
Write-Output (Get-JiraIssue -Key $_issue.Key -Credential $Credential)
139+
Write-Output (Get-JiraIssue -Key $_issue.Key -Fields $Fields -Credential $Credential)
126140
}
127141
}
128142
'ByJQL' {
@@ -134,11 +148,15 @@ function Get-JiraIssue {
134148
validateQuery = $true
135149
expand = "transitions"
136150
maxResults = $PageSize
151+
137152
}
138153
OutputType = "JiraIssue"
139154
Paging = $true
140155
Credential = $Credential
141156
}
157+
if ($Fields) {
158+
$parameter["GetParameter"]["fields"] = $Fields
159+
}
142160
# Paging
143161
($PSCmdlet.PagingParameters | Get-Member -MemberType Property).Name | ForEach-Object {
144162
$parameter[$_] = $PSCmdlet.PagingParameters.$_
@@ -158,14 +176,14 @@ function Get-JiraIssue {
158176
Invoke-JiraMethod @parameter
159177
}
160178
'ByFilter' {
161-
$filterObj = Get-JiraFilter -InputObject $Filter -Credential $Credential -ErrorAction Stop
179+
$filterObj = (Get-JiraFilter -InputObject $Filter -Credential $Credential -ErrorAction Stop).searchurl
162180
<#
163181
#ToDo:CustomClass
164182
Once we have custom classes, this will no longer be necessary
165183
#>
166184

167185
$parameter = @{
168-
URI = $filterObj.SearchUrl
186+
URI = $filterObj
169187
Method = "GET"
170188
GetParameter = @{
171189
validateQuery = $true
@@ -175,6 +193,10 @@ function Get-JiraIssue {
175193
OutputType = "JiraIssue"
176194
Paging = $true
177195
Credential = $Credential
196+
197+
}
198+
if ($Fields) {
199+
$parameter["GetParameter"]["fields"] = $Fields
178200
}
179201
# Paging
180202
($PSCmdlet.PagingParameters | Get-Member -MemberType Property).Name | ForEach-Object {

JiraPS/Public/Get-JiraIssueAttachment.ps1

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,6 @@ function Get-JiraIssueAttachment {
5959

6060
ConvertTo-JiraAttachment -InputObject $attachments
6161
}
62-
else {
63-
$errorMessage = @{
64-
Category = "ObjectNotFound"
65-
CategoryActivity = "Searching for resource"
66-
Message = "This issue does not have any attachments"
67-
}
68-
Write-Error @errorMessage
69-
}
7062
}
7163

7264
end {
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
function Get-JiraIssueAttachmentFile {
2+
# .ExternalHelp ..\JiraPS-help.xml
3+
[CmdletBinding()]
4+
[OutputType([Bool])]
5+
param (
6+
[Parameter( Mandatory, ValueFromPipeline )]
7+
[PSTypeName('JiraPS.Attachment')]
8+
$Attachment,
9+
10+
[ValidateScript(
11+
{
12+
if (-not (Test-Path $_)) {
13+
$errorItem = [System.Management.Automation.ErrorRecord]::new(
14+
([System.ArgumentException]"Path not found"),
15+
'ParameterValue.FileNotFound',
16+
[System.Management.Automation.ErrorCategory]::ObjectNotFound,
17+
$_
18+
)
19+
$errorItem.ErrorDetails = "Invalid path '$_'."
20+
$PSCmdlet.ThrowTerminatingError($errorItem)
21+
}
22+
else {
23+
return $true
24+
}
25+
}
26+
)]
27+
[String]
28+
$Path,
29+
30+
[Parameter()]
31+
[System.Management.Automation.PSCredential]
32+
[System.Management.Automation.Credential()]
33+
$Credential = [System.Management.Automation.PSCredential]::Empty
34+
)
35+
36+
begin {
37+
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"
38+
}
39+
40+
process {
41+
Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] ParameterSetName: $($PsCmdlet.ParameterSetName)"
42+
Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"
43+
44+
foreach ($_Attachment in $Attachment) {
45+
if ($Path) {
46+
$filename = Join-Path $Path $_Attachment.Filename
47+
}
48+
else {
49+
$filename = $_Attachment.Filename
50+
}
51+
52+
$iwParameters = @{
53+
Uri = $_Attachment.Content
54+
Method = 'Get'
55+
Headers = @{"Accept" = $_Attachment.MediaType}
56+
OutFile = $filename
57+
Credential = $Credential
58+
}
59+
60+
$result = Invoke-JiraMethod @iwParameters
61+
(-not $result)
62+
}
63+
}
64+
65+
end {
66+
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function ended"
67+
}
68+
}

JiraPS/Public/Get-JiraUser.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function Get-JiraUser {
7272
Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
7373
$result = Invoke-JiraMethod @parameter
7474

75-
Write-Output (ConvertTo-JiraUser -InputObject $result)
75+
Get-JiraUser -UserName $result.Name
7676
}
7777
"ByInputObject" {
7878
$UserName = $InputObject.Name

JiraPS/Public/New-JiraIssue.ps1

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,46 @@ function New-JiraIssue {
22
# .ExternalHelp ..\JiraPS-help.xml
33
[CmdletBinding( SupportsShouldProcess )]
44
param(
5-
[Parameter( Mandatory )]
5+
[Parameter( Mandatory, ValueFromPipelineByPropertyName )]
66
[String]
77
$Project,
88

9-
[Parameter( Mandatory )]
9+
[Parameter( Mandatory, ValueFromPipelineByPropertyName )]
1010
[String]
1111
$IssueType,
1212

13-
[Parameter( Mandatory )]
13+
[Parameter( Mandatory, ValueFromPipelineByPropertyName )]
1414
[String]
1515
$Summary,
1616

17+
[Parameter( ValueFromPipelineByPropertyName )]
1718
[Int]
1819
$Priority,
1920

21+
[Parameter( ValueFromPipelineByPropertyName )]
2022
[String]
2123
$Description,
2224

25+
[Parameter( ValueFromPipelineByPropertyName )]
2326
[AllowNull()]
2427
[AllowEmptyString()]
2528
[String]
2629
$Reporter,
2730

31+
[Parameter( ValueFromPipelineByPropertyName )]
2832
[String[]]
2933
$Labels,
3034

35+
[Parameter( ValueFromPipelineByPropertyName )]
3136
[String]
3237
$Parent,
3338

39+
[Parameter( ValueFromPipelineByPropertyName )]
3440
[Alias('FixVersions')]
3541
[String[]]
3642
$FixVersion,
3743

44+
[Parameter( ValueFromPipelineByPropertyName )]
3845
[PSCustomObject]
3946
$Fields,
4047

@@ -46,15 +53,15 @@ function New-JiraIssue {
4653

4754
begin {
4855
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"
56+
}
4957

58+
process {
5059
$server = Get-JiraConfigServer -ErrorAction Stop -Debug:$false
5160

5261
$createmeta = Get-JiraIssueCreateMetadata -Project $Project -IssueType $IssueType -Credential $Credential -ErrorAction Stop -Debug:$false
5362

5463
$resourceURi = "$server/rest/api/latest/issue"
55-
}
5664

57-
process {
5865
Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] ParameterSetName: $($PsCmdlet.ParameterSetName)"
5966
Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"
6067

@@ -161,9 +168,9 @@ function New-JiraIssue {
161168
Write-Output (Get-JiraIssue -Key $result.Key -Credential $Credential)
162169
}
163170
}
171+
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete"
164172
}
165173

166174
end {
167-
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete"
168175
}
169176
}

JiraPS/Public/Set-JiraIssue.ps1

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ function Set-JiraIssue {
5656
$Credential = [System.Management.Automation.PSCredential]::Empty,
5757

5858
[Switch]
59-
$PassThru
59+
$PassThru,
60+
61+
[Switch]
62+
$SkipNotification
6063
)
6164

6265
begin {
@@ -175,14 +178,21 @@ function Set-JiraIssue {
175178
}
176179
}
177180

181+
$SkipNotificationParams = @{}
182+
if ($SkipNotification) {
183+
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Skipping notification for watchers"
184+
$SkipNotificationParams = @{notifyUsers = $false}
185+
}
186+
178187
if ( @($issueProps.update.Keys).Count -gt 0 ) {
179188
Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Updating issue fields"
180189

181190
$parameter = @{
182-
URI = $issueObj.RestUrl
183-
Method = "PUT"
184-
Body = ConvertTo-Json -InputObject $issueProps -Depth 10
185-
Credential = $Credential
191+
URI = $issueObj.RestUrl
192+
Method = "PUT"
193+
Body = ConvertTo-Json -InputObject $issueProps -Depth 10
194+
Credential = $Credential
195+
GetParameter = $SkipNotificationParams
186196
}
187197
Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
188198
if ($PSCmdlet.ShouldProcess($issueObj.Key, "Updating Issue")) {
@@ -196,10 +206,11 @@ function Set-JiraIssue {
196206
# you customize the "Edit Issue" screen.
197207

198208
$parameter = @{
199-
URI = "{0}/assignee" -f $issueObj.RestUrl
200-
Method = "PUT"
201-
Body = ConvertTo-Json -InputObject $assigneeProps
202-
Credential = $Credential
209+
URI = "{0}/assignee" -f $issueObj.RestUrl
210+
Method = "PUT"
211+
Body = ConvertTo-Json -InputObject $assigneeProps
212+
Credential = $Credential
213+
GetParameter = $SkipNotificationParams
203214
}
204215
Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
205216
if ($PSCmdlet.ShouldProcess($issueObj.Key, "Updating Issue [Assignee] from JIRA")) {

0 commit comments

Comments
 (0)