使用python的jira库操作jira的版本单和问题单链接

操作JIRA的API来实现的。

但感觉比单纯操作API要简单一些。

from jira import JIRA
from django.conf import settings


JIRA_URL = settings.JIRA['URL']
USER = settings.JIRA['USER']
PASSWORD = settings.JIRA['PASSWORD']
jira_client = JIRA(server=JIRA_URL, basic_auth=(USER, PASSWORD))

def search_jira_version(request):
    # site_id = request.GET.get('site_id')
    project = jira_client.project('ECO')
    versions = jira_client.project_versions(project)
    version_list = []
    for v in reversed(versions):
        tmp_dict = dict()
        tmp_dict[v.id] = v.name
        version_list.append(tmp_dict)
        if len(version_list) > 5:
            break
    return JsonResponse({"versions": version_list})


def search_jira_issue(request):
    # site_id = request.GET.get('site_id')
    version_name = request.GET.get('version_name')
    project = jira_client.project('ECO')
    issue_list = []
    jql = "project = {} AND fixVersion = {}".format(project.name, version_name)
    max_results = 30
    try:
        issues = jira_client.search_issues(jql, maxResults=max_results)
        for issue in issues:
            tmp_dict = dict()
            tmp_dict[issue.id] = str(issue)
            issue_list.append(tmp_dict)
    except Exception as e:
        print(e)
    return JsonResponse({"issues": issue_list})

前端稍作ajax操作,就可以出来关联菜单选择了。

转载于:https://www.cnblogs.com/aguncn/p/11007566.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值