Python导出Jira列表

python 复制代码
import  requests
import urllib3
urllib3.disable_warnings()
from jira import  JIRA
import pandas as pd
def login_jira(username,password):
    jira = JIRA("https://jira.cn/",basic_auth=(username,password))
    #projects=jira.project(id=13)
    # jql='project="云链-供应链中台-材料域" AND created >= 2020-07-1 AND created <=now() '
    testIssue = jira.issue("jira-13244")
    print(testIssue)
    #issues=jira.search_issues('project="PS" AND creator=currentUser() order by created DESC', maxResults=1000)
    issues=jira.search_issues('project="PS" AND assignee=currentUser()  AND updated > "-1d"  AND assignee=currentUser() AND (status="待处理" OR status="开发中" OR status="待开发" OR status = "重新打开" OR status = "修复中") order by priority DESC', maxResults=1000)
    a=["key","标题","状态","子任务","createtime","项目名","link","优先级",'解决时间',"对应开发","问题类型","问题报告人"]


    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.description, issue.fields.versions[0].name if len(issue.fields.versions)>0 else None,
        #      issue.fields.resolutiondate, issue.fields.assignee, issue.fields.issuetype,"陈权"]
        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.resolutiondate, issue.fields.assignee, issue.fields.issuetype,"测试"]

        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","优先级",'解决时间',"对应开发","问题类型","问题报告人"])


    return jira

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

if __name__ == '__main__':
    login_jira("user","pswd")
python 复制代码
import  requests
import urllib3
urllib3.disable_warnings()
from jira import  JIRA
import pandas as pd
def login_jira(username,password):
    jira = JIRA("https://jira.cn/",basic_auth=(username,password))
    #projects=jira.project(id=13)
    # jql='project="云链-供应链中台-材料域" AND created >= 2020-07-1 AND created <=now() '
    testIssue = jira.issue("jira-13244")
    print(testIssue)
    #issues=jira.search_issues('project="PS" AND creator=currentUser() order by created DESC', maxResults=1000)
    issues=jira.search_issues('project="PS" AND assignee=currentUser()  AND updated > "-1d"  AND assignee=currentUser() AND (status="待验证" OR status="开发中" OR status="进行中" OR status="修复中") order by priority DESC', maxResults=1000)
    a=["key","标题","状态","子任务","createtime","项目名","link","优先级",'解决时间',"对应开发","问题类型","问题报告人"]


    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.description, issue.fields.versions[0].name if len(issue.fields.versions)>0 else None,
        #      issue.fields.resolutiondate, issue.fields.assignee, issue.fields.issuetype,"陈权"]
        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.resolutiondate, issue.fields.assignee, issue.fields.issuetype,"测试"]

        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","优先级",'解决时间',"对应开发","问题类型","问题报告人"])


    return jira

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

if __name__ == '__main__':
    login_jira("user","pswd")

创作不易,小小的支持一下吧!

相关推荐
小二·18 分钟前
java基础面试题笔记(基础篇)
java·笔记·python
小喵要摸鱼2 小时前
Python 神经网络项目常用语法
python
一念之坤3 小时前
零基础学Python之数据结构 -- 01篇
数据结构·python
wxl7812274 小时前
如何使用本地大模型做数据分析
python·数据挖掘·数据分析·代码解释器
NoneCoder4 小时前
Python入门(12)--数据处理
开发语言·python
LKID体4 小时前
Python操作neo4j库py2neo使用(一)
python·oracle·neo4j
小尤笔记5 小时前
利用Python编写简单登录系统
开发语言·python·数据分析·python基础
FreedomLeo15 小时前
Python数据分析NumPy和pandas(四十、Python 中的建模库statsmodels 和 scikit-learn)
python·机器学习·数据分析·scikit-learn·statsmodels·numpy和pandas
007php0075 小时前
GoZero 上传文件File到阿里云 OSS 报错及优化方案
服务器·开发语言·数据库·python·阿里云·架构·golang
Tech Synapse5 小时前
Python网络爬虫实践案例:爬取猫眼电影Top100
开发语言·爬虫·python