java系统找不到指定文件怎么解决
360
2022-11-01
Jira Python REST API 使用
python jira 库
REST API :project 下的所有具有 issuelink 的上级 issue 的变化 不区分 link 的关联方式 不关注下级 issue 的变化 当 issuelink 的上级 issue 发生变化,将改变写入下级 issuelink 的 comment 里, 由 jira 触发邮件通知给 Assignee 、Reporter.
#!/usr/bin/env python3.8 # coding=utf-8 import datetime as dt from jira import JIRA class GetJiraIssueDetail: def __init__(self): self.jira_basic_auth = ('$jira_username', '$jira_password') self.jira_server = JIRA(basic_auth=self.jira_basic_auth, options={'server': 'http://jira.test.cn'}) """ 查询 project 下 issuetype 为 "Story" 且 resolution 为 "Unresolved" 且 status 为 "To Do" 和 "In Progress" maxResults=-1 表示返回全部的结果,默认搜索返回前50个结果 """ def get_issue_from_project(self, project_key): """ Get issue from project :param project_key: jira project key :return: list[Issue Info] """ try: issues = self.jira_server.search_issues(('project = "%s" AND issuetype = "Story" AND resolution = "Unresolved" AND status in ("To Do","In Progress") ORDER BY priority DESC, updated DESC') % (project_key), maxResults=-1) return issues except Exception as getIssueError: return getIssueError def get_issue_comments(self, issue_key): """ Get issue comments :param issue_key: issue key :return: List[Comment Info] """ try: issue_comment = self.jira_server.comments(issue_key) return issue_comment except Exception as getCommentError: return getCommentError """ 获取 issue 的 history,issue 所有的改动不包括添加 comment ,都会记录到 changelog 中 """ def get_issue_changelog(self, issue_key, expand=None): """ Get issue change log :param issue_key: issue key :return: """ try: issue_changelog = self.jira_server.issue(issue_key, expand=expand) return issue_changelog except Exception as getChangelogError: return getChangelogError """ 获取过去 24 小时的 issue changelog 和 comment,将更改写入 issuelink 的 comment 里 """ def update_issuelinks_comment(self, issue_key): """ Gets issue changes made in the last 24 hours, Write the changes to Issuelink comment :param issue_key: :return: """ now_time = dt.datetime.now() given_time = now_time - dt.timedelta(hours=24) issue_changelog = self.get_issue_changelog(issue_key, expand="changelog") if issue_changelog.fields.issuelinks: for issuelink in issue_changelog.fields.issuelinks: try: print(issue_key, issuelink.outwardIssue.key) # 判断下 issuelink 是否为 outwardIssue,也就是是否为下级 issuelink,如果是 inwardIssue,说明该 issue 是另外一个 issue 的 link,这里我们只关注上级 issue 的变化 if issuelink.outwardIssue.fields.status: for history in issue_changelog.changelog.histories: changelog_update_time = dt.datetime.strptime(history.created, '%Y-%m-%dT%H:%M:%S.%f+0800') # Get issue change log in the last 24 hours if changelog_update_time > given_time: for item in history.items: changelog_comment_text = "The parent link %s changes the %s at %s, Change From: %s , Modified contents: %s" % (issue_changelog.key, item.field, changelog_update_time, history.author, item.toString) print(changelog_comment_text) # Write the parent link's changes to the child link's comments self.jira_server.add_comment(issuelink.outwardIssue.key, changelog_comment_text) # Get issue comments in the last 24 hours issue_comments = self.get_issue_comments(issue_key) for comment in issue_comments: comment_create_time = dt.datetime.strptime(comment.created, "%Y-%m-%dT%H:%M:%S.%f+0800") if comment_create_time > given_time: comment_text = "The parent link %s added a comment at %s, Comment from: %s Content of comments: %s" % (issue_changelog.key, comment_create_time, comment.author.displayName, comment.body) print(comment_text) # Write the parent link's changes to the child link's comments self.jira_server.add_comment(issuelink.outwardIssue.key, comment_text) except Exception as error: return error if __name__ == '__main__': issueLinkNotify = GetJiraIssueDetail() issues = issueLinkNotify.get_issue_from_project(project_key="DEV") for issue in issues: if issue.fields.issuelinks: issueLinkNotify.update_issuelinks_comment(issue_key=issue.key)
Jira中最常用的JQL搜索语句
JQL 语法:
JQL 语法简介
JIRA 的 JQL 语法由以下几个元素组成
field (字段) : 就是要搜索的JIRA Issue 的各个字段operator(运算符或者也叫操作符):如 =, < , > , in 等value(值):具体要查询的字段匹配的值keyword(关键字): keyword这个字面上理解可能会带来些歧义, 主要有以下作用连接两个表达式,即通常我们所说的逻辑运算符:AND, OR, NOT排序运算符:ORDERBY还有一部分就是表示空的关键字: NULL 和 EMPTY,这两个貌似才是通常意义上的关键字function(方法):即JIRA提供的一些方法,如 now()表示当前时间,currentUser()表示当前用户等
参考博客:
未完待续...
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~