日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無先后,達(dá)者為師

網(wǎng)站首頁 編程語言 正文

python操作jira添加模塊的方法_python

作者:晨+燕 ? 更新時(shí)間: 2022-05-18 編程語言

JIRA介紹:

? ? ? JIRA是Atlassian公司出品的項(xiàng)目與事務(wù)跟蹤工具,被廣泛應(yīng)用于缺陷跟蹤、需求收集、流程審批、任務(wù)跟蹤、項(xiàng)目跟蹤和敏捷管理等工作領(lǐng)域.

? ? ? 在開發(fā)工作中,Jira通常用作BUG管理和任務(wù)跟蹤管理等,項(xiàng)目經(jīng)理,測試人員,開發(fā)人員等在Jira上進(jìn)行提交BUG,提交任務(wù),修改任務(wù)進(jìn)度等操作.下面我們看下python操作jira添加模塊的方法。

python操作jira

首先安裝jira模塊

$ pip install jira

導(dǎo)入jira模塊

from jira import JIRA
import xlrd # 導(dǎo)入xlrd,xlrd可以支持讀取xls文件,不支持讀取xlsx

編寫添加模塊代碼

下面展示一些 內(nèi)聯(lián)代碼片

def add_module_to_jira(jiraurl,username,password,modulename,projectKey):
    myjira = JIRA(jiraurl, basic_auth=(username, password))
    myjira.create_component(modulename,projectKey)

獲取當(dāng)前項(xiàng)目的模塊信息

def get_project_compopents(jiraurl,username,password,projectKey):
    myjira = JIRA(jiraurl, basic_auth=(username, password))
    return  myjira.project_components(projectKey)

從excel表讀取信息

def read_xls(xls_path,sheetName):
    worksheet = xlrd.open_workbook(xls_path)  # 打開excel文件,參數(shù)為文件的路徑
    sheet_names = worksheet.sheet_names()  # 獲取excel文件的所有sheet頁,返回名字列表,
    # sheet_name=worksheet.sheet_by_name('Sheet1')#
    print(sheet_names)
    # print(sheet_name)
    sheet = worksheet.sheet_by_name(sheetName)  # 獲取到sheet名稱為Sheet1的sheet頁
    row = sheet.nrows  # 獲取文件行數(shù)
    cow = sheet.ncols  # 獲取文件列數(shù)
    scores = sheet.col_values(4, 1, row)
    scoreslsit = []
    for score in scores:
        # scorelist = score.split('&')
        # print(scorelist)
        print(score)
        scoreslsit.append(score)
    return scoreslsit

主方法中調(diào)用添加模塊等方法

ss=get_project_compopents(jiraurl,username,password,projectKey=projectkey)
    module=[]
    print(ss)
    for one in ss:
        print(one.name)
        module.append(one.name)
    print('ssss',len(ss))
    print(module)
    print("module:",len(module))
    modunameList = read_xls(r'D:\test9.xls', 'Sheet1')
    print(modunameList)
    print("modulist的長度",len(modunameList))
    modulenew=[]
    moduleold=[]
    for one in modunameList:
        if one in module:
            moduleold.append(one)
            continue
        else:
            modulenew.append(one)
    print("modulnew的內(nèi)容如下:")
    print(modulenew)
    print("modulnew的長度是",len(modulenew))
    print("moduleOld是------------")
    print(moduleold)
    print("moduleOld是------------")
    for moduname in modulenew:
        print(moduname)
        add_module_to_jira(jiraurl=jiraurl,username=username,password=password,modulename=moduname,projectKey=projectkey)

原文鏈接:https://blog.csdn.net/wangchao_ad/article/details/123509125

欄目分類
最近更新