如何在JIRA中将发布设置为“已发布”

问题描述 投票:0回答:1

我有一个名为ASDF的董事会,在Relaeses选项卡下的董事会中,我有一个名为QWER的版本。这个版本有3个问题。

如果所有问题都处于“完成”状态,我想将版本的状态更改为“已发布”。我不知道如何将状态更改为“已发布”。

我试图使用JIRA-Python REST-API来做到这一点。我也对CLI方法持开放态度。

jira python-jira
1个回答
0
投票

实现这一目标的最佳方法是通过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)

你不会在任何地方传递自己,你只需要调用jira实例的函数:

jira.version_count_unresolved_issues('QWER')

你根本没有通过自我,jira实例会自动在幕后传递,请查看python-jira文档以获取更多信息:https://jira.readthedocs.io/en/master/examples.html

© www.soinside.com 2019 - 2024. All rights reserved.