python jira 数据爬取bug和子任务清单

import  requests
import urllib3
urllib3.disable_warnings()
from jira import  JIRA
import pandas as pd
def login_jira(username,password):
    jira = JIRA("https://jira.mypaas.com.cn",basic_auth=(username,password))
    projects=jira.project(id=10902)
    # jql='project="云链-供应链中台-材料域" AND created >= 2020-07-1 AND created <=now() '
    issues=jira.search_issues('project="云链-供应链中台-材料域" AND creator=currentUser() order by created DESC', maxResults=1000)
    a=["key","标题","状态","子任务","createtime","项目名","link","优先级",'version','解决时间',"对应开发","问题类型","问题报告人"]


    datas=[]
    for index,issue in enumerate(issues):
   
        b = [issue.key, issue.fields.summary, issue.fields.status, issue.fields.subtasks, issue.fields.created,
             issue.fields.project.name,
             issue.self, issue.fields.priority,  issue.fields.versions[0].name if len(issue.fields.versions)>0 else None,
             issue.fields.resolutiondate, issue.fields.assignee, issue.fields.issuetype,"ppt"]

        datas.append(b)
    print(datas)

    df=pd.DataFrame(datas,columns=a)
    # pd.DataFrame.from_dict(datas,orient='index',columns=[a])
    print(df)
    df_tmp=df.query("状态!='完成'")
    df_tmp.to_csv("./static_excel_ptt.csv", encoding='utf_8_sig',header=["key","标题","状态","子任务","createtime","项目名","link","优先级",'version','解决时间',"对应开发","问题类型","问题报告人"])


    return jira

def get_comments_content(issue):
    return [comment.body for comment in issue.fields.comment.comments]

if __name__ == '__main__':
    login_jira("pengtt01","hello")

  

posted @ 2020-08-17 14:17  不带R的墨菲特  阅读(1024)  评论(0编辑  收藏  举报