jira - 如何在 JIRA 中将发布设置为“已发布”
问题描述
我有一个名为 ASDF 的板,在 Relaeses 选项卡下的那个板上,我有一个名为:QWER 的版本。这个版本有 3 个问题。
如果所有问题都处于“完成”状态,我想将版本的状态更改为“已发布”。我不知道如何将状态更改为“已发布”。
我正在尝试使用 JIRA-Python REST-API 来做到这一点。我也对 CLI 方法持开放态度。
解决方案
完成此任务的最佳方法是通过Jira Automation Plugin。请记住,我与此插件没有任何关系;但是,我确实有使用它的经验,它非常适合这个目的。对于 python-jira 解决方案,请记住这将更加困难。首先,您必须检查所有问题是否已完成,这可以通过以下方式完成:
def version_count_unresolved_issues(self, id):
"""Get the number of unresolved issues for a version.
:param id: ID of the version to count issues for
"""
return self._get_json('version/' + id + '/unresolvedIssueCount')['issuesUnresolvedCount']
所以我们通过一些条件检查如下:
if not jira.version_count_unresolved_issues('QWER'):
jira.move_version(...)
该move_version
函数如下所示:
def move_version(self, id, after=None, position=None):
"""Move a version within a project's ordered version list and return a new version Resource for it.
One, but not both, of ``after`` and ``position`` must be specified.
:param id: ID of the version to move
:param after: the self attribute of a version to place the specified version after (that is, higher in the list)
:param position: the absolute position to move this version to: must be one of ``First``, ``Last``,
``Earlier``, or ``Later``
"""
data = {}
if after is not None:
data['after'] = after
elif position is not None:
data['position'] = position
url = self._get_url('version/' + id + '/move')
r = self._session.post(
url, data=json.dumps(data))
version = Version(self._options, self._session, raw=json_loads(r))
return version
关于您的评论,请查看文档摘录:
from jira import JIRA
import re
# By default, the client will connect to a JIRA instance started from the Atlassian Plugin SDK
# (see https://developer.atlassian.com/display/DOCS/Installing+the+Atlassian+Plugin+SDK for details).
# Override this with the options parameter.
options = {
'server': 'https://jira.atlassian.com'}
jira = JIRA(options)
您不会在任何地方传递 self ,您只需jira
像这样调用实例的函数:
jira.version_count_unresolved_issues('QWER')
您根本不传递 self,jira 实例在幕后自动作为 self 传递,请查看 python-jira 文档以获取更多信息: https ://jira.readthedocs.io/en/master/examples .html
推荐阅读
- python-3.x - pygame表面中的numpy数组中除红色、绿色和蓝色之外的不同颜色
- javascript - 为什么 JSON.parse 适用于 1 元素数组?
- r - 将多重插补数据集提取到数据框列表中
- python - Django RestAPI,公开一个函数而不是一个模型
- android - 无法在回收站视图中制作选框
- javascript - 存储在数组中的 IP 地址列表,只有第一个八位字节,我需要向范围内的任何人显示特定消息
- javascript - 如何在 react-native json 中插入多维数组数据?
- reactjs - 在反应中测试滑块组件
- pine-script - 从第一个索引确定烛台的总数
- jdbc - Snowflake JDBC 驱动元数据提取自定义属性