日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

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

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

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

# 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

#讀取表數(shù)據(jù)
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]

#根據(jù)讀取數(shù)據(jù)新建任務(wù)
@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['測試環(huán)境id']
    system_module_value = test_data['信增系統(tǒng)模塊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"新建的任務(wù)已創(chuàng)建,其ID為:{new_issue.key}")
    except Exception as e:
        print('異常: %s' % e)

    finally:

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


總結(jié)

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

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。