ankitpokhrel / jira-cli

🔥 Feature-rich interactive Jira command line.
MIT License
4.02k stars 213 forks source link

`clone` command does not clone custom field values #499

Open coltoneakins opened 2 years ago

coltoneakins commented 2 years ago

Describe the bug

As it stands, the jira clone command does not really 'clone' issues in the same way Jira actually would. Issue custom fields are not copied over at all (the custom fields listed in .config/.jira/.config.yml).

Part of my .config.yml file:

issue:
    fields:
        custom:
            - name: Story Points
              key: customfield_10103
              schema:
                datatype: number
            - name: Stakeholders
              key: customfield_13875
              schema:
                datatype: array
                items: option
            - name: Epic Link
              key: customfield_11405
              schema:
                datatype: any
            - name: Sprint
              key: customfield_10801
              schema:
                datatype: array
                items: string
            - name: Parent Link
              key: customfield_13803
              schema:
                datatype: any
            - name: Epic Name
              key: customfield_11407
              schema:
                datatype: string

None of these custom fields are copied over when cloning an issue.

For instance, when cloning issue:

ISSUE-12345

to

ISSUE-12346

The cloned issue does not have custom fields set at all.

Please provide following details

  1. JiraCLI Version:
    (Version="1.1.0", GitCommit="3b93e147eac468ad985bdece27469153b4bb2814", CommitDate="2022-08-14T08:10:40+00:00", GoVersion="go1.18.3", Compiler="gc", Platform="darwin/arm64")
  2. Are you using Jira cloud or on-premise jira server? Also mention the version for on-premise installation.
    Jira on-premise, Jira v8.22.6
  3. What operating system are you using? Also mention version.
    macOS Monterey v12.4
  4. What terminal are you using? Also mention version.
    Hyper v3.3.0

To Reproduce

Steps to reproduce the behavior:

  1. Setup jira-cli as you normally would
  2. Attempt to clone any issue with custom labels
  3. Notice that the cloned version of the issue does not have any custom fields set like that in the original issue.

Expected behavior Cloning an issue also clones the values of all custom fields.

Screenshots n/a

Additional context n/a

ankitpokhrel commented 2 years ago

Hi @coltoneakins, Jira doesn't provide any API to clone the issue. So, the clone command is fetching and re-creating the issue with the most common fields. And, custom fields are not included during this process as this will complicate things a bit. Technically, current clone command is same as issuing the create command by passing all parameters manually.

coltoneakins commented 2 years ago

@ankitpokhrel - Based on your experience, would it be 'infeasible' to adjust the command to:

  1. Read the custom fields from the source issue then
  2. Set the custom fields on the newly created, cloned issue

So, it 'seems' like the issue is being cloned?

I haven't worked with Jira's API extensively. So, do you think this approach would work?

philipsd6 commented 2 days ago

It would be nice to have some work done here, since without custom field support I can't even do a clone at all, as I get:

Error:
  - customfield_10007: Epic Name is required.

and of course, there's a lot of other custom fields that should be cloned as well.