Skip to content

Commit

Permalink
Merge pull request #326 from AtlassianPS/release/v2.9
Browse files Browse the repository at this point in the history
Release v2.9
  • Loading branch information
lipkau authored Dec 12, 2018
2 parents 8aa72ef + db256de commit a0e29a6
Show file tree
Hide file tree
Showing 22 changed files with 717 additions and 79 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Change Log

## [2.9] - 2018-12-12

### Added

- Parameter for selecting what fields to return the the issue's payload (#300, [@tuxgoose])
- Added pipeline support to `New-JiraIssue` (#312, [@ctolan])
- Added parameter to avoid notifying user when running `Set-JiraIssue` (#315, [@alexsuslin])
- Improved documentation to demonstrate how to authenticate with 2FA (#313, [@lipkau])
- Added function to download attachments from issue: `Get-JiraIssueAttachmentFile` (#323, [@lipkau])

### Changed

- Fixed the way a user is resolved in `Remove-JiraGroupMember` (#301, [@lipkau])
- Improved the resolving of server responses with an error (#303, [@lipkau])
- Fixed payload of `New-JiraFilter` (#304, [@lipkau])
- Fixed paging when server responds with only 1 result (#307, [@lipkau])
- Fixed `Set-JiraIssue` to allow to unassigned an issue (#309, [@lipkau])
- Changed CI/CD pipeline from AppVeyor to Azure DevOps (#317, [@lipkau])
- Fixed missing properties on `Get-JiraUser` (#321, [@lipkau])
- Fixed `-DateStarted` on `Add-JiraIssueWorklog` (#324, [@lipkau])


## [2.8] - 2018-06-28

More detailed description about the changes can be found on [Our Website](https://atlassianps.org/article/announcement/JiraPS-v2.8.html).
Expand Down Expand Up @@ -279,6 +301,7 @@ which is in turn inspired by the [Vagrant](https://github.com/mitchellh/vagrant/
[@beaudryj]: https://github.com/beaudryj
[@brianbunke]: https://github.com/brianbunke
[@Clijsters]: https://github.com/Clijsters
[@ctolan]: https://github.com/ctolan
[@colhal]: https://github.com/colhal
[@Dejulia489]: https://github.com/Dejulia489
[@ebekker]: https://github.com/ebekker
Expand All @@ -290,4 +313,5 @@ which is in turn inspired by the [Vagrant](https://github.com/mitchellh/vagrant/
[@lukhase]: https://github.com/lukhase
[@padgers]: https://github.com/padgers
[@ThePSAdmin]: https://github.com/ThePSAdmin
[@tuxgoose]: https://github.com/tuxgoose
[@WindowsAdmin92]: https://github.com/WindowsAdmin92
2 changes: 1 addition & 1 deletion JiraPS/JiraPS.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RootModule = 'JiraPS.psm1'

# Version number of this module.
ModuleVersion = '2.8'
ModuleVersion = '2.9'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
5 changes: 5 additions & 0 deletions JiraPS/Public/Add-JiraIssueWorklog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ function Add-JiraIssueWorklog {
Write-Error @errorMessage
}

# Harmonize DateStarted:
# `Get-Date -Date "01.01.2000"` does not return the local timezone
# which is required by the API
$DateStarted = [DateTime]::new($DateStarted.Ticks, 'Local')

$requestBody = @{
'comment' = $Comment
# We need to fix the date with a RegEx replace because the API does not like:
Expand Down
36 changes: 29 additions & 7 deletions JiraPS/Public/Get-JiraIssue.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ function Get-JiraIssue {
[Object]
$Filter,

[Parameter()]
[ValidateNotNullOrEmpty()]
[String[]]
$Fields = "*all",

[Parameter( ParameterSetName = 'ByJQL' )]
[Parameter( ParameterSetName = 'ByFilter' )]
[UInt32]
Expand All @@ -91,8 +96,10 @@ function Get-JiraIssue {

$server = Get-JiraConfigServer -ErrorAction Stop

$resourceURi = "$server/rest/api/latest/issue/{0}?expand=transitions"
$searchURi = "$server/rest/api/latest/search"
$resourceURi = "$server/rest/api/latest/issue/{0}"

[String]$Fields = $Fields -join ","
}

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

$getParameter = @{ expand = "transitions" }
if ($Fields) {
$getParameter["fields"] = $Fields
}

$parameter = @{
URI = $resourceURi -f $_key
Method = "GET"
Credential = $Credential
URI = $resourceURi -f $_key
Method = "GET"
GetParameter = $getParameter
Credential = $Credential
}

Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
$result = Invoke-JiraMethod @parameter

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

Write-Output (Get-JiraIssue -Key $_issue.Key -Credential $Credential)
Write-Output (Get-JiraIssue -Key $_issue.Key -Fields $Fields -Credential $Credential)
}
}
'ByJQL' {
Expand All @@ -134,11 +148,15 @@ function Get-JiraIssue {
validateQuery = $true
expand = "transitions"
maxResults = $PageSize

}
OutputType = "JiraIssue"
Paging = $true
Credential = $Credential
}
if ($Fields) {
$parameter["GetParameter"]["fields"] = $Fields
}
# Paging
($PSCmdlet.PagingParameters | Get-Member -MemberType Property).Name | ForEach-Object {
$parameter[$_] = $PSCmdlet.PagingParameters.$_
Expand All @@ -158,14 +176,14 @@ function Get-JiraIssue {
Invoke-JiraMethod @parameter
}
'ByFilter' {
$filterObj = Get-JiraFilter -InputObject $Filter -Credential $Credential -ErrorAction Stop
$filterObj = (Get-JiraFilter -InputObject $Filter -Credential $Credential -ErrorAction Stop).searchurl
<#
#ToDo:CustomClass
Once we have custom classes, this will no longer be necessary
#>

$parameter = @{
URI = $filterObj.SearchUrl
URI = $filterObj
Method = "GET"
GetParameter = @{
validateQuery = $true
Expand All @@ -175,6 +193,10 @@ function Get-JiraIssue {
OutputType = "JiraIssue"
Paging = $true
Credential = $Credential

}
if ($Fields) {
$parameter["GetParameter"]["fields"] = $Fields
}
# Paging
($PSCmdlet.PagingParameters | Get-Member -MemberType Property).Name | ForEach-Object {
Expand Down
8 changes: 0 additions & 8 deletions JiraPS/Public/Get-JiraIssueAttachment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,6 @@ function Get-JiraIssueAttachment {

ConvertTo-JiraAttachment -InputObject $attachments
}
else {
$errorMessage = @{
Category = "ObjectNotFound"
CategoryActivity = "Searching for resource"
Message = "This issue does not have any attachments"
}
Write-Error @errorMessage
}
}

end {
Expand Down
68 changes: 68 additions & 0 deletions JiraPS/Public/Get-JiraIssueAttachmentFile.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
function Get-JiraIssueAttachmentFile {
# .ExternalHelp ..\JiraPS-help.xml
[CmdletBinding()]
[OutputType([Bool])]
param (
[Parameter( Mandatory, ValueFromPipeline )]
[PSTypeName('JiraPS.Attachment')]
$Attachment,

[ValidateScript(
{
if (-not (Test-Path $_)) {
$errorItem = [System.Management.Automation.ErrorRecord]::new(
([System.ArgumentException]"Path not found"),
'ParameterValue.FileNotFound',
[System.Management.Automation.ErrorCategory]::ObjectNotFound,
$_
)
$errorItem.ErrorDetails = "Invalid path '$_'."
$PSCmdlet.ThrowTerminatingError($errorItem)
}
else {
return $true
}
}
)]
[String]
$Path,

[Parameter()]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential = [System.Management.Automation.PSCredential]::Empty
)

begin {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"
}

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

foreach ($_Attachment in $Attachment) {
if ($Path) {
$filename = Join-Path $Path $_Attachment.Filename
}
else {
$filename = $_Attachment.Filename
}

$iwParameters = @{
Uri = $_Attachment.Content
Method = 'Get'
Headers = @{"Accept" = $_Attachment.MediaType}
OutFile = $filename
Credential = $Credential
}

$result = Invoke-JiraMethod @iwParameters
(-not $result)
}
}

end {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function ended"
}
}
2 changes: 1 addition & 1 deletion JiraPS/Public/Get-JiraUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function Get-JiraUser {
Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
$result = Invoke-JiraMethod @parameter

Write-Output (ConvertTo-JiraUser -InputObject $result)
Get-JiraUser -UserName $result.Name
}
"ByInputObject" {
$UserName = $InputObject.Name
Expand Down
19 changes: 13 additions & 6 deletions JiraPS/Public/New-JiraIssue.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,46 @@ function New-JiraIssue {
# .ExternalHelp ..\JiraPS-help.xml
[CmdletBinding( SupportsShouldProcess )]
param(
[Parameter( Mandatory )]
[Parameter( Mandatory, ValueFromPipelineByPropertyName )]
[String]
$Project,

[Parameter( Mandatory )]
[Parameter( Mandatory, ValueFromPipelineByPropertyName )]
[String]
$IssueType,

[Parameter( Mandatory )]
[Parameter( Mandatory, ValueFromPipelineByPropertyName )]
[String]
$Summary,

[Parameter( ValueFromPipelineByPropertyName )]
[Int]
$Priority,

[Parameter( ValueFromPipelineByPropertyName )]
[String]
$Description,

[Parameter( ValueFromPipelineByPropertyName )]
[AllowNull()]
[AllowEmptyString()]
[String]
$Reporter,

[Parameter( ValueFromPipelineByPropertyName )]
[String[]]
$Labels,

[Parameter( ValueFromPipelineByPropertyName )]
[String]
$Parent,

[Parameter( ValueFromPipelineByPropertyName )]
[Alias('FixVersions')]
[String[]]
$FixVersion,

[Parameter( ValueFromPipelineByPropertyName )]
[PSCustomObject]
$Fields,

Expand All @@ -46,15 +53,15 @@ function New-JiraIssue {

begin {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"
}

process {
$server = Get-JiraConfigServer -ErrorAction Stop -Debug:$false

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

$resourceURi = "$server/rest/api/latest/issue"
}

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

Expand Down Expand Up @@ -161,9 +168,9 @@ function New-JiraIssue {
Write-Output (Get-JiraIssue -Key $result.Key -Credential $Credential)
}
}
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete"
}

end {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete"
}
}
29 changes: 20 additions & 9 deletions JiraPS/Public/Set-JiraIssue.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ function Set-JiraIssue {
$Credential = [System.Management.Automation.PSCredential]::Empty,

[Switch]
$PassThru
$PassThru,

[Switch]
$SkipNotification
)

begin {
Expand Down Expand Up @@ -175,14 +178,21 @@ function Set-JiraIssue {
}
}

$SkipNotificationParams = @{}
if ($SkipNotification) {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Skipping notification for watchers"
$SkipNotificationParams = @{notifyUsers = $false}
}

if ( @($issueProps.update.Keys).Count -gt 0 ) {
Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Updating issue fields"

$parameter = @{
URI = $issueObj.RestUrl
Method = "PUT"
Body = ConvertTo-Json -InputObject $issueProps -Depth 10
Credential = $Credential
URI = $issueObj.RestUrl
Method = "PUT"
Body = ConvertTo-Json -InputObject $issueProps -Depth 10
Credential = $Credential
GetParameter = $SkipNotificationParams
}
Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
if ($PSCmdlet.ShouldProcess($issueObj.Key, "Updating Issue")) {
Expand All @@ -196,10 +206,11 @@ function Set-JiraIssue {
# you customize the "Edit Issue" screen.

$parameter = @{
URI = "{0}/assignee" -f $issueObj.RestUrl
Method = "PUT"
Body = ConvertTo-Json -InputObject $assigneeProps
Credential = $Credential
URI = "{0}/assignee" -f $issueObj.RestUrl
Method = "PUT"
Body = ConvertTo-Json -InputObject $assigneeProps
Credential = $Credential
GetParameter = $SkipNotificationParams
}
Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
if ($PSCmdlet.ShouldProcess($issueObj.Key, "Updating Issue [Assignee] from JIRA")) {
Expand Down
Loading

0 comments on commit a0e29a6

Please sign in to comment.