JiraPS
JiraPS copied to clipboard
How to set Epic Link on Jira ticket creation?
I'm trying to open a story in Jira and attach it to an Epic. In my environment the "Epic Link" custom field is required.
I've tried:
$fields = @{ "Epic Link" = $issue.key }
$fields = @{ "Epic Link" = @( $issue.key ) }
$fields = @{ "Epic Link = @( @{ key = $issue.Key } ) }
where $issue.Key is from a previous ticket getting created. I get internal server errors or "String value expected as the Epic Key."
What is the correct way to do this during ticket creation?
We need more context in order to help you. Here is was I ran:
I ♥ PS> $epic = new-jiraissue -Project TV -IssueType Epic -Summary "This is an epic" -Priority 1 -Reporter admin -field @{ "Epic Name" = "This is an epic" }
I ♥ PS> $feature = new-jiraissue -Project TV -IssueType Task -Summary "This is a Feature" -Priority 1 -Reporter admin -field @{ "Epic Link" = $epic.key }
I ♥ PS> (get-jirafield "Epic Link").id
customfield_10006
I ♥ PS> $feature.customfield_10006
TV-34
That's essentially what I'm trying to do... But I'll give you my code (with all my company's bits taken out)
` $ticketparms = @{
Project = "PROJ"
IssueType = "Story"
Summary = "blah blah"
Reporter = $cred.UserName # the credentials being used to log in to Jira.. me
Description = "Something cool goes here"
Priority = 1 # Makes it a P1
Fields = @{
"Assignee" = @{ name = $cred.UserName }
"fixVersions" = @( @{ name = "string" } )
"Epic Link" = "PROJ-1234"
}
}
$issue = New-JiraIssue @ticketparms `
(Sorry for the new lines, but it all wrapped if I didn't use them) The error I get is a 500 - InternalServerError. Am I not using your code correctly?
When I use get-jirafield to get "Epic Link"'s information, it says that the schema is of type "array" which usually means I need @( and ) around the value, like this, no?
"Epic Link" = @( "PROJ-1234" )
When I do that, I get "String value expected as the Epic key".
No idea what I'm doing wrong over here....
Wow what timing! This was a super helpful bit of advice. I just went to figure this out and there's an issue from a few hours ago, lol. When this is eventually closed, do these still remain available? Trying to find a thing I can bookmark to reference.
@scottsavarese , (get-jirafield "Epic Link").id = 'PROJ-1234'
Oh... that's weird.
my Epic Link is different:
I ♥ PS> get-jirafield "Epic Link" ID : customfield_10006 Searchable : True Schema : @{type=any; custom=com.pyxis.greenhopper.jira:gh-epic-link; customId=10006} Name : Epic Link Custom : True Navigable : True Orderable : True ClauseNames : {cf[10006], Epic Link}
I was able to get this to work by doing the following:
- Find an existing case with an Epic attached and note the key.
- Run
Get-JiraIssue -Key 'JIRA-1234' | Format-List * - Track down your Epic Key from the list of fields. In my case it was
customfield_10006: JIRA-9999 - Use Get-JiraField to get the Name:
PS C:\GIT> Get-JiraField -Field 'customfield_10006'
ID : customfield_10006
Searchable : True
Schema : @{type=any; custom=com.pyxis.greenhopper.jira:gh-epic-link; customId=10006}
Name : Epic Link
Custom : True
Navigable : True
Orderable : True
ClauseNames : {cf[10006], Epic Link}
- Add the Name and the Epic Key as a string to New-JiraIssue as a Fields array:
$parameters = @{
Project = "JIRA"
IssueType = "User Story"
Fields = @{
"Epic Link" = 'JIRA-9999'
}
Summary = "Created using JiraPS"
Description = "This is a rad description"
}
$jiraIssue = New-JiraIssue @parameters
Hope this assists in others getting around this issue.