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

时间:2018-08-27 13:35:46

标签: jira python-jira

我有一个名为ASDF的委员会,在“ Relaeses”标签下的该委员会中,我有一个名为“ QWER”的版本。此版本有3个问题。

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

我正在尝试使用JIRA-Python REST-API进行此操作。我也对CLI方法持开放态度。

1 个答案:

答案 0 :(得分: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')

您根本不会传递self,jira实例会在后台自动作为self传递,请查看python-jira文档以获取更多信息: https://jira.readthedocs.io/en/master/examples.html

相关问题