AtlassianPS / JiraPS

PowerShell module to interact with Atlassian JIRA
https://AtlassianPS.org/module/JiraPS
MIT License
323 stars 131 forks source link

Fix Provided: Get-JiraUser function inside Invoke-JiraIssueTransition function can return an array of users #349

Closed mirrorgleam closed 5 years ago

mirrorgleam commented 5 years ago

Description

If JIRA has usernames such as "jsmith", "jsmithy", "jsmith1", "jsmithson" and you are trying to assign the ticket to "jsmith" it will fail because the assignee field needs a string but this function is returning an array of strings.

Steps To Reproduce

$userDetails = Get-JiraUser -UserName "jsmith" -Credential $jiraCredentials -Exact
Invoke-JiraIssueTransition -Issue "TCKT-1234" -Credential $jiraCredentials -Transition 1 -Assignee $userDetails 

Expected behavior

Ticket will be assigned to the user in $userDetails

Possible Solution

My Fix: Modified JiraPS.psm1 line 2964: if ($assigneeObj = Get-JiraUser -InputObject $Assignee -Credential $Credentials) { change: added -Exact flag to Get-JiraUser function

In https://github.com/AtlassianPS/JiraPS/blob/master/JiraPS/Public/Invoke-JiraIssueTransition.ps1 line 112

alexsuslin commented 5 years ago

Could you please submit a pull request to this issue?

mirrorgleam commented 5 years ago

I'm not familiar with pull requests but I'll look it up and try to figure out what I need to do.

lipkau commented 5 years ago

Thank you, @mirrorgleam . Here are the instructions on how to submit a Pull Request: https://atlassianps.org/docs/Contributing/#how-to-submit-code-changes

of course I would gladly support you with it :-)

mirrorgleam commented 5 years ago

Just submitted it. I hope it's up to standards. I just submitted one for the Invoke-JiraIssueTransition, should I also submit one for the JiraPS.psm1 file?

mirrorgleam commented 5 years ago

And on further review I now see that isn't necessary. Clever coding on that file. I've learned something new about PS. Also, thanks for building this module. It's been extremely helpful these past few months.

lipkau commented 5 years ago

I do not see your PR yet. https://github.com/AtlassianPS/JiraPS/pulls

can you post the link to the PR you created?

lipkau commented 5 years ago

I see your commit: https://github.com/mirrorgleam/JiraPS/commit/0a201610313d582d6effb2eb7082b2c21ae27a63

By clicking this button, you create the PR: image

This is what you should get: https://github.com/AtlassianPS/JiraPS/compare/master...mirrorgleam:mirrorgleam-patch-1?expand=1

mirrorgleam commented 5 years ago

This is what I get when I click that. image

mirrorgleam commented 5 years ago

AH THINK I FOUND IT :D

mirrorgleam commented 5 years ago

It looks like it's in your pull requests now