Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create tasks for boards with custom fields? #479

Open
kostyay opened this issue Dec 14, 2022 · 1 comment
Open

How to create tasks for boards with custom fields? #479

kostyay opened this issue Dec 14, 2022 · 1 comment

Comments

@kostyay
Copy link

kostyay commented Dec 14, 2022

Hi
I'm trying to create a new task using a cli running jira create -i Task, the response that I get doesn't contain any custom fields (im sending it to an editor).
When I try to save I get an error saying that a custom field was not provided: ERROR customfield_10059: Team is required.

I tried adding it to the config.yml file like this: customfield_10059: My Team but it didn't do anything.
How can I inject custom fields?

@kostyay
Copy link
Author

kostyay commented Dec 15, 2022

here is an answer for anyone who wishes to do it in the future:

go-jira has a predefined template for the create operation. this template does not contain your custom fields. in order to support new fields you need to edit the template.
templates are not present by default, you need to create a file in ~/.jira.d/templates/create and paste the modified template there. you can find the templates in the templates.go file.
in my case this was the solution

{{/* create template */ -}}
fields:
  project:
    key: {{ or .overrides.project "" }}
  issuetype:
    name: {{ or .overrides.issuetype "" }}
  summary: >-
    {{ or .overrides.summary "" }}
{{- if .meta.fields.priority.allowedValues}}
  priority: # Values: {{ range .meta.fields.priority.allowedValues }}{{.name}}, {{end}}
    name: {{ or .overrides.priority ""}}
{{- end}}
{{- if .meta.fields.components.allowedValues}}
  components: # Values: {{ range .meta.fields.components.allowedValues }}{{.name}}, {{end}}
  {{ range split "," (or .overrides.components "")}}
    - name: {{ . }}
  {{end}}
{{- end}}
  description: |~
    {{ or .overrides.description "" | indent 4 }}
{{- if .meta.fields.assignee}}
  assignee:
    emailAddress: {{ or .overrides.assignee "" }}
{{end -}}
{{- if .meta.fields.reporter}}
  reporter:
    emailAddress: {{ or .overrides.reporter .overrides.login }}
{{end}}
{{- if .meta.fields.customfield_10110}}
  # watchers
  customfield_10110:
  {{ range split "," (or .overrides.watchers "")}}
    - name: {{.}}
  {{end}}
    - name:
{{- end}}
{{- if .meta.fields.customfield_10059}}
  # team
  customfield_10059:  # Values: {{ range .meta.fields.customfield_10059.allowedValues }}{{.value}}, {{end}}
    value: {{ (or .overrides.team "") }}
{{- end}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant