日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

python jira 读取表数据批量新建子任务

發布時間:2024/1/16 28 coder
生活随笔 收集整理的這篇文章主要介紹了 python jira 读取表数据批量新建子任务 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

小李在Jira中處理任務時,發現一個表格數據很有趣。他決定為每一行數據創建一個新的子任務。他復制粘貼,忙得不亦樂乎。同事小張路過,好奇地問:“你在做什么?”小李得意地回答:“我在批量新建子任務,讓這些數據都活起來!”小張瞪大眼睛:“你確定這不是在玩‘俄羅斯方塊’?”
于是,有了它~

# encoding=utf-8

from jira import JIRA
from openpyxl import load_workbook
import os, pytest, traceback

jira_server = "xxxxxx"
jira_username = "xxxxx"
jira_password = "xxxxx"
file_name = 'xxxxx'
sheet_name = 'xxxx'

#獲取jira消息
def jira_info(jira_server, jira_username, jira_password):
    jira = JIRA(server=jira_server, basic_auth=(jira_username, jira_password))
    return jira

#讀取表數據
def get_TestExcel(file_name, sheet_name):
    print("======", os.getcwd())
    workbook = load_workbook(file_name)
    sheet = workbook[sheet_name]
    test_data = []
    for i in range(2, sheet.max_row + 1):
        sub_data = {}
        for j in range(1, sheet.max_column + 1):
            sub_data[sheet.cell(1, j).value] = sheet.cell(i, j).value
        test_data.append(sub_data)
    return test_data


case_data = get_TestExcel(file_name, sheet_name)

idss = ["標題: {} ".format(data["標題"]) for data in case_data]

#根據讀取數據新建任務
@pytest.mark.parametrize("test_data", case_data, ids=idss)
def test_create_task(test_data):
    project_key = test_data['項目key']
    summary = test_data['標題']
    description = test_data['描述']
    issuetype = test_data['類型id']
    assignee = test_data['指向人']
    parent = test_data['掛靠需求key']
    test_environment_value = test_data['測試環境id']
    system_module_value = test_data['信增系統模塊id']
    print('project_key:%s,summary:%s,description:%s,issuetype:%s,assignee:%s,parent:%s,test_env:%s,sys_module:%s' % (
    project_key, summary, description, issuetype, assignee, parent, test_environment_value, system_module_value))
    try:
        new_issue = jira_info(jira_server, jira_username, jira_password).create_issue(
            project={'key': str(project_key)},
            summary=str(summary),
            description=str(description),
            issuetype={'id': int(issuetype)},
            assignee={'name': str(assignee)},
            parent={'key': str(parent)},
            customfield_10265={"id": str(test_environment_value)},
            customfield_10268={"id": str(system_module_value)},
        )
        print(f"新建的任務已創建,其ID為:{new_issue.key}")
    except Exception as e:
        print('異常: %s' % e)

    finally:

        print("Operation completed. Check the error log if any issues.")


總結

以上是生活随笔為你收集整理的python jira 读取表数据批量新建子任务的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。