Fix usage of New-JiraIssue in Jira Environment with mixed classic and "next gen" projects #337
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Types of changes
Checklist