简体   繁体   English

Bamboo可以在JIRA中更改门票的状态

[英]Can Bamboo change status of tickets in JIRA

We have a Bamboo environment set up with JIRA integration. 我们在Bamboo环境中设置了JIRA集成。

Whenever a developer commits a fixed issue to git, he notes the issue number in the commit message, and indeed I can see the proper link for that issue in Bamboo, which leads into the ticket in JIRA. 每当开发人员向git提交一个固定的问题时,他都会在提交消息中注明问题编号,实际上我可以在Bamboo中看到该问题的正确链接,这会导致JIRA中的票证。

I was wondering - is there a way for Bamboo to automate setting the ticket status of every ticket committed to the build to "Ready for QA"? 我在想 - 有没有办法让Bamboo自动将每张承诺构建的门票的门票状态设置为“Ready for QA”?

So for instance, if I start a new build which has a commit of ISSUE-123 in JIRA, Bamboo will set ISSUE-123 status to "Ready for QA"? 例如,如果我在JIRA中启动了一个提交了ISSUE-123的新版本,Bamboo会将ISSUE-123状态设置为“Ready for QA”?

Yes, Bamboo can change status of tickets in JIRA. 是的,Bamboo可以更改JIRA中的门票状态。 But you will need to do a little bit of magic. 但是你需要做一点魔术。

First of all, you need to learn how to use CLI plugin for JIRA . 首先,您需要学习如何为JIRA使用CLI插件 It is a great tool (it is worth mentioning that it has become a winner of atlassian codegeist contest in 2010) for the purpose of automating routine JIRA-related tasks. 它是一个很好的工具(值得一提的是,它已成为2010年atlassian代码主义竞赛的胜利者),目的是实现常规JIRA相关任务的自动化。 Actually, there are few versions of this tool that allow automating almost all Atlassian tools (JIRA, Confluence, Bamboo, Crucible, Fisheye, Stash) via command line scripting. 实际上,这个工具的版本很少,允许通过命令行脚本自动化几乎所有Atlassian工具(JIRA,Confluence,Bamboo,Crucible,Fisheye,Stash)。 Even though it is a little bit slow, it can do pretty much everything including issue status change. 尽管它有点慢,它可以做很多事情,包括问题状态的变化。 Please note it could be used both as a JIRA plugin and as a standalone command line tool. 请注意,它既可以用作JIRA插件,也可以用作独立的命令行工具。 You need to install standalone version of JIRA CLI plugin (here is installation guide ) on the machine where your Bamboo build agent is run. 您需要在运行Bamboo构建代理的计算机上安装独立版本的JIRA CLI插件(此处为安装指南 )。

In order to fast track an issue (that is how atlassian developers call the process of changing issue statuses automatically) in JIRA, you will need to use following command: 为了快速跟踪问题 (这就是atlassian开发人员如何自动调用更改问题状态的过程),您需要使用以下命令:

java -jar jira-cli-3.3.0.jar --action progressIssue --issue ISSUE-123 --step WORKFLOW_TRANSITION_ID --user USERNAME --password PASSWORD --server http://yourjira.company.com 

Replace template option values with your actual values. 将模板选项值替换为实际值。 Important value is WORKFLOW_TRANSITION_ID as long as it specifies which workflow transition will be used in order to transfer your JIRA issue into the status you actually need. 重要的值是WORKFLOW_TRANSITION_ID ,只要它指定将使用哪个工作流转换以将JIRA问题转移到您实际需要的状态。 In order to find WORKFLOW_TRANSITION_ID , you need to check workflow that is used for the ISSUE-123. 要查找WORKFLOW_TRANSITION_ID ,您需要检查用于ISSUE-123的工作流程。 Usually, you are about to fast track issues that have the same issue type (for example, Bug, Enhancement, etc). 通常,您即将快速跟踪具有相同问题类型的问题(例如,Bug,增强等)。 Also, usually issues with the same issue type have the same workflow (for example, Bug workflow). 此外,通常具有相同问题类型的问题具有相同的工作流程(例如,Bug工作流程)。

You need to get to the administrative section of JIRA and find that workflow. 您需要访问JIRA的管理部分并找到该工作流程。 Then you need to find out ids of all transitions that lead to the status you want issue to have after your update. 然后,您需要找出所有转换的ID ,这些转换会导致您在更新后要发出的状态。 In your case you need to find 'Ready for QA' status and all its incoming transitions. 在您的情况下,您需要找到“Ready for QA”状态及其所有传入的转换。 Write down ids of those transitions and use them later in order to substitute WORKFLOW_TRANSITION_ID value in the template. 记下这些转换的ID并稍后使用它们以替换模板中的WORKFLOW_TRANSITION_ID值。

If you have transitions with ids 51, 62 and 83, then your script will look as follows: 如果您使用ID 51,62和83进行过渡,那么您的脚本将如下所示:

java -jar jira-cli-3.3.0.jar --action progressIssue --issue ISSUE-123 --step 51 --user USERNAME --password PASSWORD --server http://yourjira.company.com
java -jar jira-cli-3.3.0.jar --action progressIssue --issue ISSUE-123 --step 62 --user USERNAME --password PASSWORD --server http://yourjira.company.com
java -jar jira-cli-3.3.0.jar --action progressIssue --issue ISSUE-123 --step 83 --user USERNAME --password PASSWORD --server http://yourjira.company.com

If you need to fast track issues with other issue types and, therefore, workflows, you will need to find those workflows and find transitions that leads to 'Ready for QA' status (if it is actually used by workflow) just like you did with previous workflow. 如果您需要快速跟踪其他问题类型以及工作流程的问题,您将需要找到这些工作流程并找到导致“准备好QA”状态的转换(如果它实际上被工作流程使用),就像您使用以前的工作流

In case you are confused with all the available command line options and their values, use JIRA CLI documentation as a command line options reference. 如果您对所有可用的命令行选项及其值感到困惑,请使用JIRA CLI文档作为命令行选项参考。

After you have figured out the content of the script that is going to fast track issues to the required status (in your case 'Ready for QA'), you will need to include it into the build script used by Bamboo. 在您确定要将问题快速跟踪到所需状态的脚本内容之后(在您的“Ready for QA”中),您需要将其包含在Bamboo使用的构建脚本中。

Next step would be to store content of fast tracking script to the file: 下一步是将快速跟踪脚本的内容存储到文件中:

Bash (build.sh): Bash(build.sh):

while getopts "j:" opt; do
  case $opt in
    j)
      java -jar jira-cli-3.3.0.jar --action progressIssue --issue $OPTARG --step 51 --user USERNAME --password PASSWORD --server http://yourjira.company.com
      java -jar jira-cli-3.3.0.jar --action progressIssue --issue $OPTARG --step 62 --user USERNAME --password PASSWORD --server http://yourjira.company.com
      java -jar jira-cli-3.3.0.jar --action progressIssue --issue $OPTARG --step 83 --user USERNAME --password PASSWORD --server http://yourjira.company.com
      ;;
    \?)
      echo "No issue key has been passed: -$OPTARG" >&2
      ;;
  esac
done

Note that it uses -j option in order to specify JIRA issue key for the script as a command line argument. 请注意,它使用-j选项以将脚本的JIRA问题密钥指定为命令行参数。

Everything else depends on what build management tool you use (Ant, Maven or just plain bash). 其他一切都取决于您使用的构建管理工具(Ant,Maven或仅仅是简单的bash)。 But, in any case, you will be able to pass jira key (that bamboo gets for you from the git comment) as a command line option for the build script you use on Bamboo: 但是,无论如何,你将能够传递jira键(竹子从git注释中获取)作为你在Bamboo上使用的构建脚本的命令行选项:

Bash: 击:

./build.sh -j ${bamboo.issueKey} 

Ant: 蚂蚁:

ant -Djirakey=${bamboo.issueKey}

Maven: Maven的:

mvn -Djirakey=${bamboo.issueKey}

Last step you need is to adapt fast track code for the build management tool you use. 您需要的最后一步是为您使用的构建管理工具调整快速跟踪代码。

Ant (build.xml): Ant(build.xml):

<exec executable="bash" dir=".">
   <arg value="build.sh"/>
   <arg value="-j"/>
   <arg value="${jirakey}"/>
</exec>

For Maven it is much more complex. 对于Maven来说,它要复杂得多。 Use maven exec plugin for executing build.sh from your build script. 使用maven exec插件从您的构建脚本执行build.sh

In order to avoid writing complex build scripts, you might choose to add standalone build step on Bamboo that will be run after successful build. 为了避免编写复杂的构建脚本,您可以选择在Bamboo上添加将在成功构建后运行的独立构建步骤 But in this case you will not be able to update issue status while build is still running (actually, not sure, you want to do that). 但在这种情况下,当构建仍在运行时,您将无法更新问题状态(实际上,不确定,您希望这样做)。 Usually adding standalone build step is enough to achieve what you want. 通常添加独立构建步骤就足以实现您想要的效果。 Just put ./build.sh -j ${bamboo.issueKey} in the field 'Argument' while adding new build step on Bamboo. 只需在“Argument”字段中输入./build.sh -j ${bamboo.issueKey} ,同时在Bamboo上添加新的构建步骤。

NOTE: I didn't test any of those scripts because currently I do not have bamboo installed and do not have chance to experiment with fast tracking by CI server. 注意:我没有测试任何这些脚本,因为目前我没有安装Bamboo,也没有机会尝试CI服务器的快速跟踪。 So, be careful and make sure you understand what you are doing. 所以,要小心,确保你明白自己在做什么。

Hope my recommendations will help you to achieve what you want. 希望我的建议可以帮助您实现您想要的目标。 Good luck! 祝好运!

I know there's already an answer accepted, and it is the correct answer indeed. 我知道已经接受了答案,这确实是正确的答案。

What I think is missing from Atlassian CLI is a proper Homebrew formula to install the tools on OSX. 我认为Atlassian CLI缺少的是在OSX上安装工具的正确的Homebrew公式。

Here's the formula that I use. 这是我使用的公式。

#

require 'formula'

# Homebrew formula to install atlassian CLI tools

class NewsAtlassianCli < Formula

    version "3.6.0"

    homepage 'https://marketplace.atlassian.com/plugins/org.swift.atlassian.cli'
    url 'https://marketplace.atlassian.com/download/plugins/org.swift.atlassian.cli/version/360'
    sha1 'a56aed6b6fe19a3b59998f9aed8da0077bc9d441'

    # dependencies (if any)

    # Install
    def install

        # this is garbage
        puts "Cleaning up windows stuff and examples..."
        rm Dir["*.bat"]
        rm_rf "examples"

        # patch and move
        puts "Patching shell scripts and moving them to bin..."
        # patch by updating path to lib folder
        Dir['*.sh'].each do |f|
            system "sed -i -e 's,/lib,/../lib,g' #{f}"
        end

        # move the all to bin
        Dir.mkdir "bin"
        Dir['*.sh'].each { |f| mv f, "bin/atlas-#{f.sub('.sh', '')}" }

        prefix.install_metafiles
        prefix.install Dir['*']
    end

    test do
        puts "version: #{version}"
    end
end

As you can see, it cleans up all Windows noise and examples. 如您所见,它可以清除所有Windows噪音和示例。

Then it fixes the folder structure. 然后它修复了文件夹结构。 All the toolsets normally have bin , lib and other folders. 所有工具集通常都有binlib和其他文件夹。 Homebrew then creates links in /usr/local/bin , * /usr/local/lib and so on. Homebrew然后在/ usr / local / bin ,* / usr / local / lib等中创建链接。

Atlassian ignore this rule for reasons that I don't quite know, so the tools won't properly install. 出于我不太了解的原因,Atlassian忽略了这条规则,因此工具无法正确安装。

One way to fix it is to move all executables to bin folder, and patch them by prelacing all references to lib/... with ../lib/... . 修复它的一种方法是将所有可执行文件移动到bin文件夹,并通过使用../ lib / ...预先添加对lib / ...的所有引用来修补它们。

I also decided to drop the .sh and prepend all executables with atlas- , since atlas-all is much better than all or all.sh . 我还决定删除.sh并在atlas-之前添加所有可执行文件,因为atlas-allallall.sh好得多。

I'm still toying with an idea to contribute this formula to Homebrew. 我仍然想要为Homebrew贡献这个公式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM