JIRA的ISSUE通过后台JIRA提供的API实现工作流任务状态更新

  • Post author:
  • Post category:其他




测试前jira面板

在这里插入图片描述



jira中的工作流配置,我们要找到TransitionInput的ID

括号内ID就是TransitionInput的参数ID

在这里插入图片描述



pom文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>jiraTest</groupId>
    <artifactId>jiraTest</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-rest-java-client</artifactId>
            <version>1.1-m02</version>
        </dependency>
    </dependencies>


    <repositories>
        <repository>
            <id>aliyun-nexus</id>
            <name>aliyun-nexus</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>local-nexus</id>
            <name>local-nexus</name>
            <url>http://repo.maven.apache.org//repository/maven-public/</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
        </repository>
    </repositories>
</project>

仓库配置:因jar问题先从阿里云仓库获取,找不到在去本地仓库



测试代码

package com.jira.test;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;

import com.atlassian.jira.rest.client.JiraRestClient;
import com.atlassian.jira.rest.client.NullProgressMonitor;
import com.atlassian.jira.rest.client.domain.BasicIssue;
import com.atlassian.jira.rest.client.domain.BasicProject;
import com.atlassian.jira.rest.client.domain.Issue;
import com.atlassian.jira.rest.client.domain.User;
import com.atlassian.jira.rest.client.domain.input.FieldInput;
import com.atlassian.jira.rest.client.domain.input.IssueInput;
import com.atlassian.jira.rest.client.domain.input.IssueInputBuilder;
import com.atlassian.jira.rest.client.domain.input.TransitionInput;
import com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClientFactory;

public class jira {


    static JerseyJiraRestClientFactory factory = new JerseyJiraRestClientFactory();
    static NullProgressMonitor pm = new NullProgressMonitor();
    static String uri = "http://xxxxx:8080";
    static String user = "xxxxx";
    static String pwd = "xxxxx";

    /**
     * @param args
     */
    public static void main(String[] args) {
        URI jiraServerUri = null;
        try {
            jiraServerUri = new URI(uri);
            JiraRestClient restClient = factory
                    .createWithBasicHttpAuthentication(jiraServerUri, user, pwd);
            Issue issue = restClient.getIssueClient().getIssue("XQKB-19", pm);
            TransitionInput tinput = new TransitionInput(131);
            restClient.getIssueClient().transition(issue, tinput, pm);

        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
    }
    }



结果

在这里插入图片描述

参考:

https://my.oschina.net/erichsbc/blog/164149?p=2&temp=1475996868481

本人亲测,如有问题请留言,相互学习



版权声明:本文为qq_16149043原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。