美文网首页
python通过JIRA API获取ISSUE

python通过JIRA API获取ISSUE

作者: 87d6dc4b11a7 | 来源:发表于2024-04-15 10:33 被阅读0次
    import logging
    from jira import JIRA
    
    
    def get_issue_from_jira(issue_id):
        jira_url = "http://10.XX.XX.XX:8090"
        api_token = "XXXXXXXXXXXXXXXXX"
    
        try:
    
            # https://jira.readthedocs.io/examples.html#jira-self-hosted-incl-jira-server-data-center
            jira = JIRA(jira_url, token_auth=api_token)
    
            if not issue_id:
                return {"error": "Issue ID is required."}
    
            # https://jira.readthedocs.io/api.html#jira.client.JIRA.issue
            issue = jira.issue(issue_id)
            if issue:
                print(f"Issue details for {issue.key}:")
                print(f"Summary: {issue.fields.summary}")
                print(f"Description: {issue.fields.description}")
                print(f"Status: {issue.fields.status.name}")
                print(f"Type: {issue.fields.issuetype.name}")
            else:
                return {"error": f"Issue {issue_id} not found."}
    
        except Exception as e:
            logging.error(f"An error occurred: {e}")
            return {"error": str(e)}
    
    
    if __name__ == "__main__":
        get_issue_from_jira(issue_id="TEST-3")
    
    

    相关文章

      网友评论

          本文标题:python通过JIRA API获取ISSUE

          本文链接:https://www.haomeiwen.com/subject/awrdxjtx.html