jira-cli icon indicating copy to clipboard operation
jira-cli copied to clipboard

New Issue is not linked to Epic.

Open hugoghx opened this issue 3 years ago • 14 comments

Describe the bug Creating an issue of type "Story" and trying to link that to a parent Epic doesn't seem to work.

  1. JiraCLI Version:
(Version="v0.3.0", GitCommit="", CommitDate="", GoVersion="go1.17.5", Compiler="gc", Platform="darwin/arm64")
  1. Are you using Jira cloud or on-premise jira server? Also mention the version for on-premise installation.
Jira Cloud - Classic project
  1. What operating system are you using? Also mention version.
macOS Big Sur 11.6.2
  1. What terminal are you using? Also mention version.
iTerm 2 Build 3.4.14

To Reproduce

  1. Ran the command with the -P flag to link to an epic, as specified here. In my case jira issue create -tStory -PMYEPIC-42 [email protected]
  2. Fill in the remaining fields (Summary & Description)
  3. Story is created with the correct summary and description. It's also assigned to me, but not linked to the Epic as seen in the Story detail Epic link - It's set to None.

Expected behavior Expected the task to be linked to MYEPIC-42.


As an aside, if I set the issue type to Sub-task, it seems to link it to the Epic properly, but the problem is that it doesn't show on the right pane on jira epic view. I tried some other types but none worked. jira epic view seems to list all issue types linked to an epic but Sub-task.

hugoghx avatar Feb 01 '22 19:02 hugoghx

Hi @hugoamvieira, to confirm you are using next-gen project and not classic right?

ankitpokhrel avatar Feb 01 '22 20:02 ankitpokhrel

Hey @ankitpokhrel - Nope, it's a classic project.

As per the config:

project:
  key: <REDACTED>
  type: classic

hugoghx avatar Feb 02 '22 17:02 hugoghx

Are you able to set epic using jira epic add? Attaching issue on creation seem to be working fine in my setup (cloud) so I might need some extra details to debug. Is this epic shown when you try to add it from the UI ?

ankitpokhrel avatar Feb 02 '22 18:02 ankitpokhrel

Are you able to set epic using jira epic add?

Yep. Hadn't tried this but it works like a charm - I created a test Story and added it to an Epic and it worked great :)

Is this epic shown when you try to add it from the UI ?

Yep - I can set the epic in Jira's UI just fine.

hugoghx avatar Feb 02 '22 23:02 hugoghx

@hugoamvieira this can only happen if the config doesn't have value for epic.link. Could you please check and confirm that the generated config file has valid value for epic section? Please try regenerating the config with jira init if the value is missing.

ankitpokhrel avatar Feb 10 '22 17:02 ankitpokhrel

@ankitpokhrel Yep - You're correct. epic.link is set to "". I tried regenerating but it's still not setting anything in there - What should be in that value?

hugoghx avatar Feb 10 '22 18:02 hugoghx

epic.link is a custom field and is populated using /rest/api/2/issue/createmeta endpoint. It would be helpful If you can execute following curl command and see if the API returns Epic Link custom field for your project.

curl --request GET \
  --url 'https://<HOST>.atlassian.net/rest/api/2/issue/createmeta?projectKeys=<KEY>&expand=projects.issuetypes.fields' \
  --user "<USER>:$JIRA_API_TOKEN" > createmeta.json

In the response:

  • we are first looking for projects.issuetypes with "name": "Epic" and,
  • in the fields section of that block there should be a custom field with name Epic Link

epic.link is value for that custom field eg customfield_10104

ankitpokhrel avatar Feb 10 '22 19:02 ankitpokhrel

Hey @ankitpokhrel - So I found the projects.issuetypes with "name": "Epic", however there's no custom field within it that has name Epic Link.

This custom field is present in other issuetypes though - Here's how it looks like on other issue types:

                        "customfield_10008": {
                            "required": false,
                            "schema": {
                                "type": "any",
                                "custom": "com.pyxis.greenhopper.jira:gh-epic-link",
                                "customId": 10008
                            },
                            "name": "Epic Link",
                            "key": "customfield_10008",
                            "hasDefaultValue": false,
                            "operations": [
                                "set"
                            ]
                        }

I'm still a bit confused into what goes into epic.link VS epic.name as jira init set epic.name to one of those customfield_XXXXXX, and epic.link to nothing.

Thanks!

hugoghx avatar Feb 14 '22 17:02 hugoghx

@hugoamvieira its strange that the response doesn't have "Epic Link" field for issue type "Epic". Does the issue link on create work if you manually add customfield_10008 to epic.link ?

ankitpokhrel avatar Feb 19 '22 09:02 ankitpokhrel

@ankitpokhrel Actually, yep. I set it up like this:

epic:
  name: "customfield_10008"
  link: "customfield_10008"

And it ended up working!

hugoghx avatar Feb 20 '22 00:02 hugoghx

Hopefull this helps someone. After running Jira Init, this is how my config looked (after changing project type to classic).

board:
    id: 1619
    name: <project_name>
    type: kanban
epic:
    name: customfield_12271
    link: ""
installation: Local
issue:
    fields:
        custom:
            ...
            - name: Epic Link
              key: customfield_12270
              schema:
                datatype: any
            ...
project:
    key: <project_key>
    type: classic
...

The epic.name field had a value of customfield_12271 so I tried setting the epic.link to the same customfield_12271. This didnt work and I got the following error:

- customfield_12271: Field 'customfield_12271' cannot be set. It is not on the appropriate screen, or unknown.

I noticed that the issues.fields.custom.Epic Link had a value of customfield_12270. So I updated my config to following and it worked!

epic:
    name: customfield_12270
    link: customfield_12270

All in all, in order to get my config to work with an on-prem Jira instance, I did the following:

  • Changed project type to classic
  • Updated Epic link to the value of the custom field Epic Link
  • (optional; personal preference) Updated custom fields names to not have spaces: Epic Link --> epic_link

Hope this helps.

PrimordialLight avatar Sep 17 '22 03:09 PrimordialLight

Thank you - this fixed it for me.

bobobox avatar Oct 13 '22 17:10 bobobox