Jenkins / Maven发布更新JIRA门票

时间:2014-06-02 18:15:35

标签: maven jenkins jira jenkins-plugins

使用Jenkins和Maven(2或3)构建系统,有没有办法:

*向另一个环境(比如说UAT)发布一个版本,并将处于一种状态(等待UAT版本)的JIRA票证更新到另一个状态(为UAT做好准备)?

M2 Release Plugin似乎是发布声明的简单答案,但是对于更新JIRA票证,无法找到帮助自动化该方法的解决方案。

如果有人完成了这样的任务,请寻求反馈!

类似的问题: What are the options for release management using Jenkins

单个故障单触发器与“版本”触发......一旦特定JIRA故障单类型的所有故障单达到“等待UAT发布”的状态,就会很简单地触发'发布' '在一个版本中。 Is there a way to trigger a Jenkins job based on the status of a JIRA ticket?

Jenkins的JIRA插件 jira update ticket using script https://wiki.jenkins-ci.org/display/JENKINS/JIRA+Plugin

1 个答案:

答案 0 :(得分:2)

这是我实施的一个解决方案,用于更新和转移jenkins作业分发到工件库的相关工件的问题。

我使用python JIRA模块来完成此任务。您可以在这里找到更多信息:

https://jira-python.readthedocs.org/en/latest/

我将这个python脚本称为执行构建的容器作业结束时的构建步骤。

这要求您为问题定义JIRA工作流,该工作流具有执行适当功能的转换(将问题从一个州转换到另一个州。)

from jira.client import JIRA

def add_artifacts_and_transition_ticket(issue, artifact_urls):
    """ write our urls to the jira ticket provided
    by jenkins and mark issue as Release Candidate in Test """

    jira = JIRA(options={'server': 'https://myjiraserver', 'verify':False},
            basic_auth=('jira_username', 'somePassword'))
    issue = jira.issue(issue)

    # add the artifacts urls to the jira ticket
    jira.add_comment(issue, 'A new RC artifact set is now available:\n' + '\n'.join(artifact_urls))

    # transition the issue from Create Release 
    # Candidate to Release Candidate In Test
    #'161' is the unique id of the my jira workflow transition
    # your transition ID will probably differ.
    # "Create Release Candidate", defined by jira admin

    jira.transition_issue(issue, '161')

if __name__ == '__main__':
    # sample call
    artifact_urls = ['url1', 'url2']
    issue = 'PROJECT_FOO-99999'
    add_artifacts_and_transition_ticket(issue, artifact_urls)