Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v2.10 #340

Merged
merged 30 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
df39805
fixes 320 - assignment when similar users exist
Jan 9, 2019
6e38104
-Exact for Get-JiraUser
Jan 9, 2019
fd6f3a1
missing }
Jan 9, 2019
eb8c09a
adding documentation to Get-JiraUser -Exact
Jan 10, 2019
adf6e40
fixing Get-JiraUser -Exact unit test
Jan 10, 2019
acff336
Exact in Get-JiraUser is not applicable for -Self set
Jan 10, 2019
74a3f61
trying to figure out the documentation requirements
Jan 10, 2019
95d5474
Fixed documentation of new parameter
lipkau Jan 10, 2019
d21c011
Added description of implementation to CHANGELOG
lipkau Jan 10, 2019
18e876d
Merge pull request #328 from michalporeba/GetUserExact
lipkau Jan 11, 2019
9db4972
Fixed logic of how to retrieve components from project
lipkau Jan 11, 2019
c6c21df
Removed debug messages from test file
lipkau Jan 11, 2019
34ec197
Merge branch 'develop' into fix/329-FixComponentInput
lipkau Jan 11, 2019
de6851a
Merge branch 'develop' into fix/OutputInTestFiles
lipkau Jan 11, 2019
04bb079
Merge pull request #331 from lipkau/fix/OutputInTestFiles
lipkau Jan 12, 2019
43a9416
Merge branch 'develop' into fix/329-FixComponentInput
lipkau Jan 12, 2019
8e9c1b9
Merge pull request #330 from lipkau/fix/329-FixComponentInput
lipkau Jan 12, 2019
ef1034f
Fix setting Accept header based on Mime time of attachment
Jan 22, 2019
53476e7
** Modify ConvertTo-JiraProject to additionally store the 'style' val…
pdx-nojp Feb 15, 2019
89e61fa
** Modify Get-JiraIssueCreateMetadata and New-JiraIssue to do proper …
pdx-nojp Feb 15, 2019
51d5d46
** Update unit tests for Get-JiraIssueCreateMetadata and New-JiraIssu…
pdx-nojp Feb 15, 2019
fc1c0c9
** Fix use of Get-JiraUser to support use with a session or a credent…
pdx-nojp Feb 18, 2019
52e421c
Merge pull request #337 from nojp/fix/NextGen-Project
lipkau Feb 18, 2019
41e8ddf
Merge branch 'develop' into get-jiraissueattachmentfile_mimetype
lipkau Feb 21, 2019
a42a82b
Merge pull request #333 from wisemoth/get-jiraissueattachmentfile_mim…
lipkau Feb 21, 2019
e5ea95f
Fixed the case of the get parameter to skip notifications on issue up…
lipkau Feb 21, 2019
7ec4a10
Merge pull request #339 from AtlassianPS/fix/#338-IncorrectHandlingOf…
lipkau Feb 21, 2019
d8de272
Updated changelog for v2.10
lipkau Feb 21, 2019
e2b8419
Removed posts from this repo
lipkau Feb 21, 2019
e8d92b7
Bumped module version to v2.10
lipkau Feb 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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