jira流转issue条目状态transitions的rest实用脚本,issue状态改变调整

官方文档链接地址:

POST

Transition issue

Performs an issue transition and, if the transition has a screen, updates the fields from the transition screen.

sortByCategory To update the fields on the transition screen, specify the fields in the fields or update parameters in the request body. Get details about the fields using Get transitions with the transitions.fields expand.

This operation can be accessed anonymously.

Permissions required:

Connect app scope required : WRITE

OAuth 2.0 scopes required:

Classic RECOMMENDED:write:jira-work

Granular :write:issue:jira, write:issue.property:jira

实用json请求脚本如下:

复制代码
{
  "transition": {
    "id": "%s"
  },
  "fields": {
    "resolution": {
      "name": "Fixed"
    }
  }
}

id参数是通过transitions api来获取的,

可以参考jira获取issue条目transitions id,以用来进行流转实用脚本_锐湃的博客-CSDN博客

示例代码如下:

复制代码
        // The payload definition using the Jackson library
        JsonNodeFactory jnf = JsonNodeFactory.instance;
        ObjectNode payload = jnf.objectNode();
        {
            ObjectNode transition = payload.putObject("transition");
            {
                transition.put("id", "81");//"91"
            }
        }

// Connect Jackson ObjectMapper to Unirest
        Unirest.setObjectMapper(new ObjectMapper() {
            private com.fasterxml.jackson.databind.ObjectMapper jacksonObjectMapper
                    = new com.fasterxml.jackson.databind.ObjectMapper();

            @Override
            public <T> T readValue(String value, Class<T> valueType) {
                try {
                    return jacksonObjectMapper.readValue(value, valueType);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            @Override
            public String writeValue(Object value) {
                println("writeValue=====" + value);
                try {
                    return jacksonObjectMapper.writeValueAsString(value);
                } catch (JsonProcessingException e) {
                    throw new RuntimeException(e);
                }
            }
        });

// This code sample uses the  'Unirest' library:
// http://unirest.io/java.html
                                                         //"https://your-domain.atlassian.net/rest/api/2/issue/issueIdOrKey/transitions"
        HttpResponse<JsonNode> response = Unirest.post("https://jira.example.com/rest/api/2/issue/TEST-7/transitions")
                .basicAuth("User", "TOKEN")
                .header("Accept", "application/json")
                .header("Content-Type", "application/json")
                .body(payload)
                .asJson();

        System.out.println(response.getBody());

本次上送的请求json如下

复制代码
{
  "transition": {
    "id": "81"
  }
}

执行成功后返回null打印出来,如果没有成功会返回失败的原因

执行成功后会发现issue已关闭

比如现在有一个需求要把TEST项目的处于待验证(已解决)状态的issue关闭;

对于这个需求可以分为三步:

1、通过search issue条目rest api获取到当前处于已解决待验证状态的issue,并把issueKeyOrId收集起来;

可以参考:jira搜索search issue条目rest实用脚本_锐湃的博客-CSDN博客

2、通过issueKeyOrId用transitions rest api获取到transitions id;

可以参考jira获取issue条目transitions id,以用来进行流转实用脚本_锐湃的博客-CSDN博客

3、用上一步获取的的id作为参数调用 文章开头的rest api请求就可以关闭流转issue了

相关推荐
杨过姑父3 小时前
部署开源版禅道,修改apache端口无效解决
bug·apache·软件工程·issue
yanweijie03173 小时前
Excel-vlookup -多条件匹配,返回指定列处的值
excel
Channing Lewis5 小时前
sql server如何创建表导入excel的数据
数据库·oracle·excel
沉到海底去吧Go21 小时前
【工具教程】PDF电子发票提取明细导出Excel表格,OFD电子发票行程单提取保存表格,具体操作流程
pdf·excel
开开心心就好1 天前
高效Excel合并拆分软件
开发语言·javascript·c#·ocr·排序算法·excel·最小二乘法
沉到海底去吧Go2 天前
【行驶证识别成表格】批量OCR行驶证识别与Excel自动化处理系统,行驶证扫描件和照片图片识别后保存为Excel表格,基于QT和华为ocr识别的实现教程
自动化·ocr·excel·行驶证识别·行驶证识别表格·批量行驶证读取表格
Abigail_chow3 天前
EXCEL如何快速批量给两字姓名中间加空格
windows·microsoft·excel·学习方法·政务
xiaohezi3 天前
Rag chunk 之:Excel 文档解析
excel
weixin_472339463 天前
python批量解析提取word内容到excel
python·word·excel
4 天前
Unity与Excel表格交互热更方案
unity·游戏引擎·excel