AtlassianPS / JiraPS

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

Cannot get or set assignee of issues #404

Closed Growlert closed 4 years ago

Growlert commented 4 years ago

Description

Seems like something is broken on the Jira side yesterday. I'm not able anymore to get issue assignee by name or set it, the property "name" of assignee is now empty.

Steps To Reproduce

(Get-JiraIssue "issue_key").assignee.name returns nothing Set-JiraIssue -Issue "issue_key" -Assignee "user_name" returns no error, but nothing assigned

Expected behavior

Should work as expected

Screenshots

Your Environment

Get-Module JiraPS -ListAvailable | Select Name, Version
$PSVersionTable

Possible Solution

rschmidt2 commented 4 years ago

I have the same issue using Get-JiraIssue -Query "project in (ITHD) AND status != Closed AND status != Resolved AND status != Done AND status != Canceled ) ORDER BY assignee, priority DESC, updated DESC" | select key, assignee, duedate, updated, created, summary, components. This is in a daily email script that just started acting up on Feb 13th.

mattiaswolff commented 4 years ago

We see exactly the same issue..

PS J:\Powershell\Functions> Get-Module JiraPS -ListAvailable | Select Name, Version

Name   Version
----   -------
JiraPS 2.12.5
JiraPS 2.9.0

PS J:\Powershell\Functions> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.18362.628
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.628
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
nathan-aung commented 4 years ago

yea, same issue here.

Get-Module JiraPS -ListAvailable | Select Name, Version

Name Version


JiraPS 2.12.5 JiraPS 2.9.0

rizickus commented 4 years ago

Same here!


JiraPS 2.12.5

Name                           Value
----                           -----
PSVersion                      5.1.18362.628
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.628
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1```
lipkau commented 4 years ago

The changes in the api of the cloud are not that trivial. And to make matter worse, the changes do not apply to jira server. Deprecation notice and migration guide for major changes to Jira Cloud REST APIs to improve user privacy

I got a few things working again. But it's not yet finished: https://github.com/lipkau/JiraPS/commit/a8a31883bacb4efee0657976c71b9d560b0ae41d

LaurentGoderre commented 4 years ago

In the case of creating a new issue the line that fails is here:

https://github.com/AtlassianPS/JiraPS/blob/master/JiraPS/Public/New-JiraIssue.ps1#L100

Can it become somethign like:

$user=$(Get-JiraUser -Credential $Credentia)
If ([string]::IsNullOrEmpty($user.Name)) {
  $requestBody["reporter"] = @{"accountId" = "$user.AccountId"}
} Else {
  $requestBody["reporter"] = @{"name" = "$user.Name"}
}
vyacheslavshcherbak commented 4 years ago

Get-JiraUser returns blank Name for all users. Please fix it ASAP.

LaurentGoderre commented 4 years ago

@vyacheslav-shcherbak-globallogic-com I don't think that will happen, JIRA remove that field from the API. This is just a wrapper for the API.

vyacheslavshcherbak commented 4 years ago

@vyacheslav-shcherbak-globallogic-com I don't think that will happen, JIRA remove that field from the API. This is just a wrapper for the API.

Will it possible to reassign a Jira issue to an another user in another way while this functionality does not work? When are you going to fix it? Can somebody to rewrite this to use AccountId instead of Name, eg.

Set-JiraIssue -Issue $IssueKey -Assignee (Get-JiraUser -UserName "$($UserName)").AccountId -Credential $Cred

instead of this

Set-JiraIssue -Issue $IssueKey -Assignee (Get-JiraUser -UserName "$($UserName)") -Credential $Cred

Growlert commented 4 years ago

Set-JiraIssue -Issue $IssueKey -Assignee (Get-JiraUser -UserName "$($UserName)").AccountId -Credential $Cred

Not working. It throws me the error: Invoke-JiraMethod : Specified user does not exist or you do not have required permissions

BigHouseITGuy commented 4 years ago

For those of you looking for a workaround, I think this will do the trick:

$assignTo = "BigHouseITGuy"

$jiraUserData = get-jirauser -UserName $assignTo -exact | Select-Object *

$accountIdObject = [pscustomobject]@{
    accountId = $jiraUserData.accountId
}

$fields = @{
    'assignee' = $accountIdObject
}

Set-JiraIssue -Issue $issue.key -Fields $fields

This also works for reporter.

Growlert commented 4 years ago

Thanks BigHouseITGuy. Your solution works like a charm! You saved a lot of manual work!

vyacheslavshcherbak commented 4 years ago

Thanks @BigHouseITGuy . Your solution with small changes works for me too!

LaurentGoderre commented 4 years ago

@vyacheslavshcherbak I am not involved with this project, just a user like you who tried to debug this issue.

rikkiprince commented 4 years ago

Thank @BigHouseITGuy. That workaround was really helpful!