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

Fix usage of New-JiraIssue in Jira Environment with mixed classic and "next gen" projects #337

Merged
merged 4 commits into from
Feb 18, 2019

Conversation

nojp
Copy link

@nojp nojp commented Feb 15, 2019

Description

Modified ConvertTo-JiraProject to store the 'style' value returned from project REST API so a given project can be differentiated between next-gen or classic.

Modified New-JiraIssue (and similarly to Get-JiraIssueCreateMetadata) to avoid use of Get-JiraIssueType - all the data that required this cmdlet to be called is already stored in $projectObj. Additionally, Get-JiraIssueType does not support mixed environments with classic and next-gen projects. The original errors we got were a result of Get-JiraIssueType returning multiple IDs for a given Issue Type name.

New-JiraIssue also had an issue with the "reporter" field being unset on a next-gen project. Classic projects seems to automatically set the reporter field to the current user if not set, but next-gen projects do not seem to behave the same, so I modified New-JiraIssue to force setting the reporter field if the target project is flagged 'next-gen' from the style field.

Finally, added some more helpful error handling in both New-JiraIssue and Get-JiraIssueCreateMetadata - previously an unhelpful error message was presented to the user if the selected Issue Type was not valid for the input Project, after this fix the error returned to the user is explicit about the input Issue Type being invalid for the Project.

Unit tests for the two Public functions needed to be updated to provide the requisite IssueTypes data on the Mock Get-JiraProject stubs.

Motivation and Context

With current develop branch, New-JiraIssue presents an error in our staging and development Jira instances:

New-JiraIssue -Project "TP1" -IssueType "Task" -Summary "Test test 123" -Priority 1 -Description "Test test 321"
Get-Member : You must specify an object for the Get-Member cmdlet.
At C:\shareDocs\Programming\JiraPS\JiraPS\Private\ConvertTo-JiraCreateMetaField.ps1:14 char:28

  • ... eldNames = (Get-Member -InputObject $fields -MemberType '*Property'). ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : CloseError: (:) [Get-Member], InvalidOperationException
    • FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • I have added Pester Tests that describe what my changes should do.
  • I have updated the documentation accordingly.

…ue returned - for use with differentiating between classic and 'next-gen' Jira projects
…error handling when the input IssueType value is not valid for the input Project value

** Modify Get-JiraIssueCreateMetadata and New-JiraIssue to use data already returned from Get-JiraProject, saving an API call and some filtering work in Get-JiraIssueType
…e to support their usage of IssueTypes data returned from Get-JiraProject
@ghost ghost added the Status:In Review label Feb 15, 2019
@nojp nojp marked this pull request as ready for review February 15, 2019 23:47
@nojp nojp requested review from a team as code owners February 15, 2019 23:47
Copy link
Member

@lipkau lipkau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.
Only one improvement, so that this also supports users that don't use sessions:

JiraPS/Public/New-JiraIssue.ps1 Outdated Show resolved Hide resolved
@lipkau lipkau assigned lipkau and nojp and unassigned lipkau Feb 16, 2019
@lipkau lipkau added this to the Next Minor milestone Feb 16, 2019
@nojp
Copy link
Author

nojp commented Feb 18, 2019

I added a commit to make Get-JiraUser support non-session users, as requested.

@lipkau lipkau merged commit 52e421c into AtlassianPS:develop Feb 18, 2019
@ghost ghost removed the Status:In Review label Feb 18, 2019
@lipkau lipkau mentioned this pull request Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants