Skip to content

Commit

Permalink
Merge pull request #340 from lipkau/release/v2.10
Browse files Browse the repository at this point in the history
Release v2.10
  • Loading branch information
lipkau authored Feb 21, 2019
2 parents a0e29a6 + e8d92b7 commit 14a4842
Show file tree
Hide file tree
Showing 23 changed files with 126 additions and 605 deletions.
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Change Log

## [NEXT VERSION] - YYYY-MM-DD

## [2.10] - 2019-02-21

### Added

- Parameter for retrieving information about a specific user with `Get-JiraUser` (#328, [@michalporeba])
- this implementations will be changed with the next major update in favor of #306

### Changed

- Fixed logic of how to retrieve components from project (#330, [@lipkau])
- Fix usage of `New-JiraIssue` in Jira Environment with mixed classic and "next gen" projects (#337, [@nojp])
- Fixed `Get-JiraIssueAttachmentFile` to use `Accept` header based on Mime time of attachment (#333, [@wisemoth])
- Fixed incorrect handling of skip notifications when updating an issue (#339, [@lipkau])

## [2.9] - 2018-12-12

### Added
Expand All @@ -21,7 +37,6 @@
- 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 @@ -311,7 +326,10 @@ which is in turn inspired by the [Vagrant](https://github.com/mitchellh/vagrant/
[@LiamLeane]: https://github.com/LiamLeane
[@lipkau]: https://github.com/lipkau
[@lukhase]: https://github.com/lukhase
[@michalporeba]: https://github.com/michalporeba
[@nojp]: https://github.com/nojp
[@padgers]: https://github.com/padgers
[@ThePSAdmin]: https://github.com/ThePSAdmin
[@tuxgoose]: https://github.com/tuxgoose
[@WindowsAdmin92]: https://github.com/WindowsAdmin92
[@wisemoth]: https://github.com/wisemoth
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.9'
ModuleVersion = '2.10'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
1 change: 1 addition & 0 deletions JiraPS/Private/ConvertTo-JiraProject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function ConvertTo-JiraProject {
'Roles' = $i.roles
'RestUrl' = $i.self
'Components' = $i.components
'Style' = $i.style
}

if ($i.projectCategory) {
Expand Down
32 changes: 14 additions & 18 deletions JiraPS/Public/Get-JiraComponent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,22 @@ function Get-JiraComponent {

switch ($PSCmdlet.ParameterSetName) {
"ByProject" {
if ($Project.PSObject.TypeNames -contains 'JiraPS.Project') {
Write-Output (Get-JiraComponent -ComponentId ($Project.Components).id)
}
else {
foreach ($_project in $Project) {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Processing [$_project]"
Write-Debug "[$($MyInvocation.MyCommand.Name)] Processing `$_project [$_project]"

if ($_project -is [string]) {
$parameter = @{
URI = $resourceURi -f "/project/$_project/components"
Method = "GET"
Credential = $Credential
}
Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
$result = Invoke-JiraMethod @parameter
foreach ($_project in $Project) {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Processing [$_project]"
Write-Debug "[$($MyInvocation.MyCommand.Name)] Processing `$_project [$_project]"

Write-Output (ConvertTo-JiraComponent -InputObject $result)
}
if ($_project -isnot [string]) {
$_project = $_project.Key
}
$parameter = @{
URI = $resourceURi -f "/project/$_project/components"
Method = "GET"
Credential = $Credential
}
Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
$result = Invoke-JiraMethod @parameter

Write-Output (ConvertTo-JiraComponent -InputObject $result)
}
}
"ByID" {
Expand Down
2 changes: 1 addition & 1 deletion JiraPS/Public/Get-JiraIssueAttachmentFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function Get-JiraIssueAttachmentFile {
$iwParameters = @{
Uri = $_Attachment.Content
Method = 'Get'
Headers = @{"Accept" = $_Attachment.MediaType}
Headers = @{"Accept" = $_Attachment.MimeType}
OutFile = $filename
Credential = $Credential
}
Expand Down
12 changes: 11 additions & 1 deletion JiraPS/Public/Get-JiraIssueCreateMetadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@ function Get-JiraIssueCreateMetadata {
Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"

$projectObj = Get-JiraProject -Project $Project -Credential $Credential -ErrorAction Stop
$issueTypeObj = Get-JiraIssueType -IssueType $IssueType -Credential $Credential -ErrorAction Stop
$issueTypeObj = $projectObj.IssueTypes | Where-Object -FilterScript {$_.Id -eq $IssueType -or $_.Name -eq $IssueType}

if ($null -eq $issueTypeObj.Id)
{
$errorMessage = @{
Category = "InvalidResult"
CategoryActivity = "Validating parameters"
Message = "No issue types were found in the project [$Project] for the given issue type [$IssueType]. Use Get-JiraIssueType for more details."
}
Write-Error @errorMessage
}

$parameter = @{
URI = $resourceURi -f $projectObj.Id, $issueTypeObj.Id
Expand Down
7 changes: 6 additions & 1 deletion JiraPS/Public/Get-JiraUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ function Get-JiraUser {
[Parameter( Position = 0, Mandatory, ParameterSetName = 'ByInputObject' )]
[Object[]] $InputObject,

[Parameter( ParameterSetName = 'ByInputObject' )]
[Parameter( ParameterSetName = 'ByUserName' )]
[Switch]$Exact,

[Switch]
$IncludeInactive,

Expand All @@ -37,6 +41,7 @@ function Get-JiraUser {

$selfResourceUri = "$server/rest/api/latest/myself"
$searchResourceUri = "$server/rest/api/latest/user/search?username={0}"
$exactResourceUri = "$server/rest/api/latest/user?username={0}"

if ($IncludeInactive) {
$searchResourceUri += "&includeInactive=true"
Expand Down Expand Up @@ -80,7 +85,7 @@ function Get-JiraUser {
$PsCmdlet.ParameterSetName = "ByUserName"
}
"ByUserName" {
$resourceURi = $searchResourceUri
$resourceURi = if ($Exact) { $exactResourceUri } else { $searchResourceUri }

foreach ($user in $UserName) {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Processing [$user]"
Expand Down
16 changes: 15 additions & 1 deletion JiraPS/Public/New-JiraIssue.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,17 @@ function New-JiraIssue {
Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"

$ProjectObj = Get-JiraProject -Project $Project -Credential $Credential -ErrorAction Stop -Debug:$false
$IssueTypeObj = Get-JiraIssueType -IssueType $IssueType -Credential $Credential -ErrorAction Stop -Debug:$false
$issueTypeObj = $projectObj.IssueTypes | Where-Object -FilterScript {$_.Id -eq $IssueType -or $_.Name -eq $IssueType}

if ($null -eq $issueTypeObj.Id)
{
$errorMessage = @{
Category = "InvalidResult"
CategoryActivity = "Validating parameters"
Message = "No issue types were found in the project [$Project] for the given issue type [$IssueType]. Use Get-JiraIssueType for more details."
}
Write-Error @errorMessage
}

$requestBody = @{
"project" = @{"id" = $ProjectObj.Id}
Expand All @@ -85,6 +95,10 @@ function New-JiraIssue {
if ($PSCmdlet.MyInvocation.BoundParameters.ContainsKey("Reporter")) {
$requestBody["reporter"] = @{"name" = "$Reporter"}
}
elseif ($ProjectObj.Style -eq "next-gen"){
Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] Adding reporter as next-gen projects must have reporter set."
$requestBody["reporter"] = @{"name" = "$((Get-JiraUser -Credential $Credential).Name)"}
}

if ($Parent) {
$requestBody["parent"] = @{"key" = $Parent}
Expand Down
4 changes: 2 additions & 2 deletions JiraPS/Public/Set-JiraIssue.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function Set-JiraIssue {
$validAssignee = $true
}
else {
if ($assigneeObj = Get-JiraUser -UserName $Assignee -Credential $Credential) {
if ($assigneeObj = Get-JiraUser -UserName $Assignee -Credential $Credential -Exact) {
Write-Debug "[$($MyInvocation.MyCommand.Name)] User found (name=[$($assigneeObj.Name)],RestUrl=[$($assigneeObj.RestUrl)])"
$assigneeString = $assigneeObj.Name
$validAssignee = $true
Expand Down Expand Up @@ -181,7 +181,7 @@ function Set-JiraIssue {
$SkipNotificationParams = @{}
if ($SkipNotification) {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Skipping notification for watchers"
$SkipNotificationParams = @{notifyUsers = $false}
$SkipNotificationParams = @{notifyUsers = "false"}
}

if ( @($issueProps.update.Keys).Count -gt 0 ) {
Expand Down
1 change: 0 additions & 1 deletion Tests/Functions/Get-JiraIssueAttachmentFile.Unit.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ Describe "Get-JiraIssueAttachmentFile" -Tag 'Unit' {
}

It 'uses Invoke-JiraMethod for saving to disk' {
$script:ShowMockData = $true
Get-JiraIssueAttachment -Issue "Foo" | Get-JiraIssueAttachmentFile
Get-JiraIssueAttachment -Issue "Foo" | Get-JiraIssueAttachmentFile -Path "../"

Expand Down
15 changes: 6 additions & 9 deletions Tests/Functions/Get-JiraIssueCreateMetadata.Unit.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -218,23 +218,20 @@ Describe "Get-JiraIssueCreateMetadata" -Tag 'Unit' {
}

Mock Get-JiraProject -ModuleName JiraPS {
$issueObject = [PSCustomObject] @{
ID = 2
Name = 'Test Issue Type'
}
$issueObject.PSObject.TypeNames.Insert(0, 'JiraPS.IssueType')
$object = [PSCustomObject] @{
ID = 10003
Name = 'Test Project'
}
Add-Member -InputObject $object -MemberType NoteProperty -Name "IssueTypes" -Value $issueObject
$object.PSObject.TypeNames.Insert(0, 'JiraPS.Project')
return $object
}

Mock Get-JiraIssueType -ModuleName JiraPS {
$object = [PSCustomObject] @{
ID = 2
Name = 'Test Issue Type'
}
$object.PSObject.TypeNames.Insert(0, 'JiraPS.IssueType')
return $object
}

Mock ConvertTo-JiraCreateMetaField -ModuleName JiraPS {
$InputObject
}
Expand Down
16 changes: 16 additions & 0 deletions Tests/Functions/Get-JiraUser.Unit.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ Describe "Get-JiraUser" -Tag 'Unit' {
ConvertFrom-Json -InputObject $restResult
}

# Get exact user
Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $URI -like "$jiraServer/rest/api/*/user?username=$testUsername"} {
ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri'
ConvertFrom-Json -InputObject $restResult
}

# Viewing a specific user. The main difference here is that this includes groups, and the first does not.
Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $URI -like "$jiraServer/rest/api/*/user?username=$testUsername&expand=groups"} {
ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri'
Expand Down Expand Up @@ -138,6 +144,16 @@ Describe "Get-JiraUser" -Tag 'Unit' {

$getResult | Should Not BeNullOrEmpty

Assert-MockCalled -CommandName Invoke-JiraMethod -Exactly 1 -Scope It -ParameterFilter {$URI -like "$jiraServer/rest/api/*/user/search?*username=$testUsername*"}
Assert-MockCalled -CommandName Invoke-JiraMethod -Exactly 1 -Scope It -ParameterFilter {$URI -like "$jiraServer/rest/api/*/user?username=$testUsername&expand=groups"}
}

It "Gets information about a provided Jira exact user" {
$getResult = Get-JiraUser -UserName $testUsername -Exact

$getResult | Should Not BeNullOrEmpty

Assert-MockCalled -CommandName Invoke-JiraMethod -Exactly 1 -Scope It -ParameterFilter {$Method -eq 'Get' -and $URI -like "$jiraServer/rest/api/*/user?username=$testUsername"}
Assert-MockCalled -CommandName Invoke-JiraMethod -Exactly 1 -Scope It -ParameterFilter {$URI -like "$jiraServer/rest/api/*/user?username=$testUsername&expand=groups"}
}

Expand Down
15 changes: 7 additions & 8 deletions Tests/Functions/New-JiraIssue.Unit.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Describe "New-JiraIssue" -Tag 'Unit' {


$jiraServer = 'https://jira.example.com'
$issueTypeTest = 1

Mock Get-JiraConfigServer {
$jiraServer
Expand All @@ -56,22 +57,20 @@ Describe "New-JiraIssue" -Tag 'Unit' {
}

Mock Get-JiraProject {
$issueObject = [PSCustomObject] @{
ID = $issueTypeTest
Name = 'Test Issue Type'
}
$issueObject.PSObject.TypeNames.Insert(0, 'JiraPS.IssueType')
$object = [PSCustomObject] @{
'ID' = $Project
'Key' = "TEST"
}
Add-Member -InputObject $object -MemberType NoteProperty -Name "IssueTypes" -Value $issueObject
$object.PSObject.TypeNames.Insert(0, 'JiraPS.Project')
return $object
}

Mock Get-JiraIssueType {
$object = [PSCustomObject] @{
'ID' = $IssueType;
}
$object.PSObject.TypeNames.Insert(0, 'JiraPS.IssueType')
return $object
}

Mock Get-JiraUser {
$object = [PSCustomObject] @{
'Name' = $UserName;
Expand Down
28 changes: 0 additions & 28 deletions _posts/2017-06-24-JiraPS-v2.0.md

This file was deleted.

Loading

0 comments on commit 14a4842

Please sign in to comment.