-
-
Notifications
You must be signed in to change notification settings - Fork 249
feat: Support custom fields on issue create #319
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
Conversation
b8bb053
to
acc7b91
Compare
@ankitpokhrel how does one supplement an extant configuration with custom fields; i.e., how do I do this without re-invoking |
@realtime-neil You can generate config in a new location using XDG_CONFIG_HOME=. jira init You can then keep using the same env for subsequent commands or you can use $ XDG_CONFIG_HOME=. jira issue create
// or
$ jira issue create -c </path/to/new/.jira/.config.yml> If you don't want to run issue:
fields:
custom:
- name: Epic Link
key: customfield_10014
schema:
datatype: any
- name: Sprint
key: customfield_10020
schema:
datatype: number |
@ankitpokhrel you're suggesting that, in addition to a given existing configuration, I use |
Yes, if you want to try out this change without tampering your current config. And if this works, you can simply run |
|
fd1d3a0
to
6d39e61
Compare
@m4dc4p Thank you for testing! Yes, it will be expanded to |
@ankitpokhrel is there any facility for querying available custom fields? |
@realtime-neil From the tool, no. If you need this info to test something then you can use the following curl commands. # Get all fields
curl --request GET \
--url 'https://<server-url>/rest/api/2/field' \
--user "<user>:$JIRA_API_TOKEN"
# Get fields available on create
curl --request GET \
--url 'https://<server-url>/rest/api/2/issue/createmeta?projectKeys=<project_key>&expand=projects.issuetypes.fields' \
--user "<user>:$JIRA_API_TOKEN" |
6d39e61
to
94601f1
Compare
I'm really excited about this, thanks! But unfortunately, it doesn't seem to work for me. I get the new custom field in my config file as an jira issue create --custom CustomFieldName=value
# or with quotes
jira issue create --custom CustomFieldName="value" The issue is created with no error, however the custom field does not get added. I tried changing the datatype to Here's the corresponding bit of my config file issue:
fields:
custom:
- name: CustomFieldName
key: customfield_10082
schema:
datatype: option |
Hi @zsolt-p, the config looks ok to me. I think the problem is with case-sensitive comparison I am doing in one place. The key is derived from the name you see in the configuration and dash/hyphen (-) separated lowercase name is used as a key. So, for example if your custom field is called Could you please check and confirm if that works for you? I will make this comparison flexible if you can confirm. |
@ankitpokhrel confirming it works You're right, our custom field has an uppercase char, lowercasing it in the command makes it work, thank you i.e. jira create issue --custom customfieldname="value" for a config file that looks like this issue:
fields:
custom:
- name: CustomFieldName
key: customfield_10082
schema:
datatype: option |
Really cool stuff here! Thanks. I would like to suggest two additional features:
And obviously and interactive way of adding the fields would be awesome indeed. I'll checkout the branch to help testing! |
19bc454
to
30bfbe6
Compare
30bfbe6
to
4eb8470
Compare
@vballestra-latch Thank you for the feedback! Regarding your suggestions, there is a plan to work on a I haven't given much thought on the command to inspect meta, but that can be included if needed. Let's first see how the users will use this feature and the issues they will run into. We can then decide on the required features. |
This PR adds initial support for custom fields on the issue creation. Relates to #222. Fixes #340.
Jira supports a wide variety of datatypes when creating a custom field. Out of all formats mentioned in the Jira doc, the implementation right now doesn't support
Cascading select custom field
,Single-user picker custom field
andMulti-user picker custom field
. Support for these missing types will be added based on the request and the usecase.Implementation Details
Since we are already using the createmeta endpoint to save metadata during
jira init
process, this step is modified to save custom field details. The initialization process will now add a new sectionissue.fields.custom
to save required details about configured custom fields.Next, a new flag
--custom
is added oncreate
command that accepts a key-value pair. The key is derived from thename
you see in the configuration. This is the same name that you see in the UI making it easy to guess. Dash/hyphen (-
) separated lowercasename
is used as a key. The value depends on the datatype of the field. For some datatypes likestring
,datetime
,date
,option
, the value is a plain string (eg:--custom note="An example note"
). For array types, its a comma separated value (eg:--custom platform=iOS,Android
).Example
Given some custom fields as below:
You can use
--custom
flag to pass data for custom fieldsThe example command above creates a
story
with defined custom fields of different types as seen in the screenshot below.Caveats
The Jira API returns invalid types for some locked custom fields. For instance, for the
sprint
field the returned datatype is an array of strings or JSON depending on the Jira version used. However, that is not true since the create API expects a single numeric value for a sprint field.In such cases, the config needs to be modified manually to make the field work.
Testing
To try out this change, you can either build the app locally or install it using the following command.
Note that you will have to regenerate the config with
jira init
.