Jira - 单选自定义字段 通过接口添加选项

本文介绍了如何通过Jira的接口自动化添加单选自定义字段的选项,包括查找的相关资源、2020年更新中提到的插件方法,以及用Python编写的实现该功能的脚本。
摘要由CSDN通过智能技术生成

Jira - 单选自定义字段 通过接口添加选项

Max.Bai

2019-10

目录

Jira - 单选自定义字段 通过接口添加选项

1. 背景

2. 信息

3. 插件可以实现接口

4. python 脚本


1. 背景

Jira里面自定义字段的选择需要在admin页面配置

Administration panel > Custom fields > configure > Edit options

有没有可以自动添加的接口什么的,经过查找,找到如下资源,先行mark,待有空来验证。

2020-03-13 更新,发现插件可以实现,看第3节

 

2. 信息

原文地址 https://community.atlassian.com/t5/Answers-Developer-Questions/How-do-I-update-Jira-custom-field-via-REST-api/qaq-p/498231

摘抄一下,以免信息丢失。

Followed this tutorial: https://developer.atlassian.com/server/framework/atlassian-sdk/developing-a-rest-service-plugin/
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 &am
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值