go-jira / jira

simple jira command line client in Go
Apache License 2.0
2.68k stars 327 forks source link

Create Issues with issue-type in a national language cannot be created with option --noedit #207

Open volker-schukai opened 6 years ago

volker-schukai commented 6 years ago

I try to create an issue in one line without an editor.

Version 1.0.20

create a new issue

jira create -p myProject --noedit -iBug -o summary="Test"

works fine, but

jira create -p myProject --noedit -iAufgabe -o summary="Test"

doesn´t work.

I think it depends on the jira-api

jira issuetypes -p MyProject

returns correct:

Aufgabe:   My Description
Bug:          Bugs....

Jira-API

this api-call doesn´t work (issuetypes is empty): /rest/api/2/issue/createmeta?projectKeys=MyProject&issuetypeNames=Aufgabe&expand=projects.issuetypes.fields

this api-call works (issuetypes returned): /rest/api/2/issue/createmeta?projectKeys=MyProject&issuetypeNames=Task&expand=projects.issuetypes.fields

but if I try the following

jira create -p myProject --noedit -iTask -o summary="Test"

then I get the following message: ERROR Invalid Usage: Project MyProject and IssueType Task not found

schnoddelbotz commented 5 years ago

Came here as I had a 'similar' issue... I was unable to get the overrides to work. I'm also on a german Jira instance and it works for me now -- so I assume it's really unrelated to Jira's language. Of course, you should provide a valid issue type (as provided by jira issutypes -p YourProject).

What I didn't figure out from documentation was how to use the overrides provided via command line. Maybe docs could be improved a bit on this aspect?

Anyhow, for reference: To make -o summary=... work for one-line ticket creation, edit ~/.jira.d/templates/create and add something like shown here:

fields:

  issuetype:
    name: Bug

  {{ if .overrides.summary }}summary: {{ .overrides.summary }}{{ else }}summary: {{ end }}

  customfield_...:
    name: 'foobar'

@volker-schukai could you please give it a try and report back? If it still doesn't work, please provide the error message for your "doesn't work" command.

sucotronic commented 5 years ago

Same problem here, using jira cloud instance:

$ jira issuetypes -p PREZ 
Tarea:        Una tarea que se debe realizar.
Subtarea:     La subtarea de la incidencia.
Mejora:       La mejora o perfeccionamiento de una función o tarea existente.
Error:        <no value>
Épica:        Creado por JIRA Software - no editar ni eliminar. Tipo de incidencia para una historia del usuario grande que debe desglosarse.

But then:

$ jira create -p PREZ -i Error
usage: jira create [<flags>]

Create issue

Global flags:
      --help                   Show context-sensitive help (also try --help-long and --help-man).
  -v, --verbose ...            Increase verbosity for debugging
  -e, --endpoint=ENDPOINT      Base URI to use for Jira
  -k, --insecure               Disable TLS certificate verification
  -Q, --quiet                  Suppress output to console
      --unixproxy=UNIXPROXY    Path for a unix-socket proxy
      --socksproxy=SOCKSPROXY  Address for a socks proxy
  -u, --user=USER              user name used within the Jira service
      --login=LOGIN            login name that corresponds to the user used for authentication

Optional flags:
  -b, --browse                 Open issue(s) in browser after operation
      --editor=EDITOR          Editor to use
  -t, --template=TEMPLATE      Template to use for output
      --noedit                 Disable opening the editor
  -p, --project=PROJECT        project to create issue in
  -i, --issuetype=ISSUETYPE    issuetype in to create
  -m, --comment=COMMENT        Comment message for issue
  -o, --override=OVERRIDE ...  Set issue property
      --saveFile=SAVEFILE      Write issue as yaml to file

ERROR Invalid Usage: Project PREZ and IssueType Error not found

If I enable debug (-vvv), the client is sending:

GET /rest/api/2/issue/createmeta?projectKeys=PREZ&issuetypeNames=Error&expand=projects.issuetypes.fields

and the server is replying:

{
  "expand": "projects",
  "projects": [
    {
      "expand": "issuetypes",
      "self": "https://xxxxx.atlassian.net/rest/api/2/project/11708",
      "id": "11708",
      "key": "PREZ",
      "name": "xxxxx",
      "avatarUrls": {
        "48x48": "https://xxxx.atlassian.net/secure/projectavatar?pid=11708&avatarId=15828",
        "24x24": "https://xxxxx.atlassian.net/secure/projectavatar?size=small&pid=11708&avatarId=15828",
        "16x16": "https://xxxxx.atlassian.net/secure/projectavatar?size=xsmall&pid=11708&avatarId=15828",
        "32x32": "https://xxxxx.atlassian.net/secure/projectavatar?size=medium&pid=11708&avatarId=15828"
      },
      "issuetypes": [

      ]
    }
  ]
}
jgraglia commented 5 years ago

I had the same issue. My workaroung was to change my langage to "English (US)" in my jira profile.

Now jira issuetypes list the types in english. And I can create an issue with --issuetype Bug

Before that, my JIRA profile was in FR, and --issuetype Bogue did not work even if listed by jira issuetypes command

examinedliving commented 5 years ago

For what it's worth, the only thing that got this working for me was setting the project as an environmental variable. I didn't have a language issue, but I got the same error you did every time. When I set JIRA_PROJECT and used %JIRA_PROJECT% (I'm on Windows), it worked. Nothing else I tried did it. Doesn't make sense to me, but that's what I got.

volker-schukai commented 5 years ago

@volker-schukai could you please give it a try and report back? If it still doesn't work, please provide the error message for your "doesn't work" command.

ok, thats workaround works if I omit the argument --issuetype however, the main problem remains