In the documentation, I can see that I can only query existing values (GET method).
I need to update "Build number" field (single select list) when official build is sent to QA, via Jenkins/Hudson.
What is the best way to do that?
CLARIFICATION:
I think I didn't explain my use-case clearly enough - I don't need to update specific issue with an existing value in the select list. I need to add new value to the field itself, i.e. I need to update the meta-data. Just like Admin will do from the Administration panel > Custom fields > configure > Edit options.
This way next time a new bug would need to be created the new entry in this field, "Build number", will already be available.
The scenario is this:
Is this possible?
Community moderators have prevented the ability to post new answers.
Followed this tutorial: https://developer.atlassian.com/display/DOCS/Developing+a+REST+Service+Plugin<br< a="">>
Added following method to the Rest Resource class (MyRestResrouce.java in the tutorial).
/** * This method is to be used whenever a new option is to be added to a custom field. It will add it to the top of the list. * @param fieldId - custom field id, e.g,. customfield_10000 * @param optionVal - option value, e.g,. 4.1r1.24.67643_70 * @return */ @GET @AnonymousAllowed @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Path("/addOptionsToCustomField") public Response addOptionToCustomField(@QueryParam("fieldId") String fieldId, @QueryParam("optionVal") String optionVal) { CustomFieldManager customFldMgr = ComponentAccessor.getCustomFieldManager(); OptionsManager optionsManager = ComponentAccessor.getComponentOfType(OptionsManager.class); if (fieldId == null || fieldId.trim().equals("")) { return Response.ok(new ZRestResourceModel("default","Missing custom field id")).build(); } //error checking code snipped CustomField customField = customFldMgr.getCustomFieldObject(fieldId); //error checking code snipped List<FieldConfigScheme> schemes = customField.getConfigurationSchemes(); if (schemes != null && !schemes.isEmpty()) { FieldConfigScheme sc = schemes.get(0); MultiMap configs = sc.getConfigsByConfig(); if (configs != null && !configs.isEmpty()) { FieldConfig config = (FieldConfig) configs.keySet().iterator().next(); Options ops = optionsManager.getOptions(config); if(ops != null && ops.getOptionForValue(optionVal, null) != null) return Response.ok(... snipped Option op = optionsManager.createOption(config, null, new Long(1), optionVal); ops = optionsManager.getOptions(config); ops.moveToStartSequence(op); } } return Response.ok(new ZRestResourceModel("default","SUCCESS")).build(); }
This is not possible in JIRA out of the box, and the feature request below was raised for this:
A simple alternative which does not require development knowledge is to use the third party plugin (free) JIRA Customfield Editor:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As I understand it's not about updating an issue but about adding a value to an existing (cascading) select list / dropdown (e.g. "build number").
I'm interested in adding new entries to a (cascading) select / dropdown as well as in updating (the spelling of) existing values.
Example with (pseudo) jelly:
<!-- select field to be updated -->
<jira:updateCustomField fieldName="My Cascading Select Field" description="A really good description" > <!-- add a new entry with sub-entries -->
<jira:AddCustomFieldSelectValue value="Main Option 1"> <jira:AddCustomFieldSelectValue value="Option 1.1"/> <jira:AddCustomFieldSelectValue value="Option 1.2"/> </jira:AddCustomFieldSelectValue> <!-- change the text of an existing main entry -->
<jira:UpdateCustomFieldSelectValue value="Main Option 2" newValue="Preferred Main Option 2"> <!-- update text of an existing sub-entry -->
<jira:UpdateCustomFieldSelectValue value="Option 2.1">Option 2.1 alpha</jira:UpdateCustomFieldSelectValue> <!-- add 2 new sub-entries -->
<jira:AddCustomFieldSelectValue value="Option 2.2"/> <jira:AddCustomFieldSelectValue value="Option 2.3"/> </jira:UpdateCustomFieldSelectValue> </jira:UpdateCustomField>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you get any solution for this? We have an exact same requirement where we want to automate adding build numbers to one of JIRA's custom field available options.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you get any solution for this? We have an exact same requirement where we want to automate adding build numbers to one of JIRA's custom field available options.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is this question ever likely to get an answer from someone @ Atlassian??
The whole add a "build ID" from a CI system seems fundamental
From the API point of view, I guess the complexity is knowing which context to update the field list in. There's no link to the context from the editmeta info
Well, that and the REST api CustomFieldOption just having a SET operator, not and ADD. Maybe access the DB directly is the only opiton, if Atlassian don't want to update the API to allow this.
I guess Atlassian open up the Version field via REST, just not custom field lists. Shame that our team don't want their Version list polluted with all the CI incremental builds...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
setFieldValue action from JIRA Command Line Interface is a simple way to do this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just for reference to people who stumble across this comment, I think Bob misunderstood the OP's question. setFieldValue will only work with values that already exist in the system (at least from my testing).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I recommend you read this tutorial since updating is sometimes confusing for starters.
Please check this tutorial https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Edit+issues
and this one for an example how to set a select list value:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No. That's a type-2 plugin which you can't install on Cloud.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Will the same REST Service Plugin work for JIRA Cloud?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi vishal-gautam,
We have also the same requirement.Can you please share the info/code that how you achieved this. Million thanks in advance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vishal,
I would be VERY interested in how you have achieved this, as that is exactly the functionality our QA/SW team would like :-) I'm sure many happy watchers on this thread would be too..put it up on github!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually I ended up writing a REST plugin for this and now our QA team uses a simple script that makes a REST call to add a new build number, which is a custom field of single select list type. If anyone is interested, I can share the code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the tip re: forgetting a SQL hack :) Understood!
Maybe it's time to learn about writing a plugin, to add to my recently acquired REST+JSON expertise. I'm, rolling ot Jira to our enterprise, so a nice auto-populated build list would be great, but it looks like being beyond a simple solution.
As an aside to the OP, I've decided to make the build ref a text field for the testers to fill in, rather than a drop down. Our CI system will update the issues with the relevant build/commit data - just need the fleshy components to make sure they're entering the correct info in the first place.
Got to say the Jira REST api makes updating issues pretty simple, much easier than the Rational/IBM tools were were using.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Possibly not. They lurk here, they do answer, but they're in no way bound to.
You might want to raise it as a feature request at jira.atlassian.com, although I suspect that they already have an issue for expanding REST functions like this.
(As an aside, please forget you even thought of "access the DB directly", you'll break Jira. You must use the API one way or another)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I wouldn't stress too much about that actually. I logged all the SQL queries Jira makes when updating an issue via the web interface, and updating a custom value is quite trivial, and nothing breaks.
It doesn't show immediately in the web interface as I suspect the list is cached. But just refresh the list of custom options eg by changing the sequence of an option and they'll appear quite happily.
I agree this is not the ideal way to go, but as Jira doesn't provide an API way to do this, and I'm not typing in 400 options by hand - it seems reasonable to me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can of course edit the issue. Refer the doc at http://docs.atlassian.com/jira/REST/latest/#id162347
We used a simple python script to access Jira via REST/SOAP to do a similar requirement from in Jenkins.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi renjith,
I can able to update issue if option is already available in cascade select field. But How to add options to cascade select field through rest api?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can't. Either you need to implement your own API or automate the addition using direct HTTP POST requests. Do a live monitoring of the http requested being sent out by the browser (Live HTTP headers in Firefox) and check how an option is getting added while doing it using the standard JIRA interface. Once you get that you can mimic the same HTTP requests from your code. Also note you need to mostly atl_token to requests for the server to accept the requests (got a GET first, parse the incoming HTML to get the token and then make the POST request using that token)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.