Link GitHub workflows and deployments to Jira work items
GitHub のワークフローとデプロイを Jira にリンクする前に、次のことを行う必要があります。
When GitHub is connected to your Jira site using the GitHub for Atlassian app, workflows and deployments from GitHub Actions can be linked to work items in your software projects in Jira. If you’re new to GitHub Actions, you can get started by reading the GitHub Actions documentation set.
Use work item keys to link deployments to Jira work items
To link GitHub deployments to Jira, you must include Jira work item keys in commit messages, branch names, and pull requests.
Find the work item key for the Jira work item you want to link to, for example “DEV-2095”.
Check out a new branch in your repo, using the work item key in the branch name. For example,
git checkout -b DEV-2095-<branch-name>
.When committing changes to your branch, use the work item key in your commit message. For example,
git commit -m "DEV-2095 <summary of commit>"
.When you create a pull request, use the work item key in the pull request title.
Once a deployment has run on a linked branch, commit, or pull request, you’ll see deployment information in your Jira work items, on the board, and on the deployments timeline.
Jira で GitHub ビルドを表示する
GitHub workflows are displayed as “builds” in Jira. They’re shown on the development panel in Jira work items, on work item cards on your Jira board, and in the Releases hub.
You must have the project permission “View Development Tools” to see the Development panel in Jira work items. How to update project permissions
A build will be automatically linked to a Jira work item if the work item key is found in any commit messages related to the pull request. If you merge a branch without a pull request, only the last commit message of that branch will be checked for Jira work item keys.
上の図を例として使用して、main
ブランチから分岐しているフィーチャー ブランチが 2 つあり、フィーチャー ブランチ (緑のドット) と main
ブランチ (青のドット) の両方のすべてのコミットで、コードベースを構築してテストするワークフローがトリガーされるように GitHub Actions が設定されていると仮定します。
By including Jira work item keys (JIRA-*
) in your commit messages, you can link specific workflow runs to their related Jira work items. For instance:
Workflow run #6 will be associated with Jira work items
JIRA-1
andJIRA-2
Workflow run #7 will be associated with Jira work items
JIRA-1
,JIRA-10,
andJIRA-11
Workflow run #2 will be associated with the Jira work items
JIRA-1
onlyJIRA-1
とJIRA-2
は両方とも同じプル リクエストの一部であるため、ワークフロー実行 #4 はこれら両方に関連付けられます。
GitHub ワークフローをプル リクエストで実行できるようにするには、プル リクエストのソース ブランチのブランチ名パターンをワークフロー設定で次のように指定する必要があります。
on:
pull_request:
branches:
- main
- feature**
View GitHub deployments in Jira
Deployments from GitHub are shown on the development panel in Jira work items, on work item cards on your Jira board, in the Releases hub, and in the deployments timeline on the Deployments page. To add deployments to your GitHub Actions workflow, you must create a deployment action in GitHub using the action chrnorm/deployment-action@releases/v1
.
The GitHub for Atlassian app only listens to deployment_status
events. This means GitHub deployments will only be shown in Jira if they meet the following conditions:
デプロイが GitHub のデプロイ作成 API または
chrnorm/deployment-action@releases/v1
アクションを使用して作成されています。デプロイ作成後、デプロイ ステータス作成 API または
chrnorm/deployment-status@releases/v1
アクションを少なくとも 1 回呼び出して、デプロイのステータスをアップデートする必要があります。
The GitHub for Atlassian app identifies new GitHub deployments by scanning deployed branches for new commit messages that contain Jira work item keys.
上の図を例に取り、main
ブランチから分岐するフィーチャー・ブランチが 2 つあり、main
ブランチでプッシュするたびにデプロイがトリガーされるように GitHub Actions が設定されていると仮定します。
If you include Jira work item keys (JIRA-*
) in your commit messages, you'll see relevant deployments in the corresponding Jira work items. For instance:
Failed deployment #6 will appear in Jira work items
JIRA-1
andJIRA-2
Deployment #7 will be visible in all related Jira work items (because none of the commits have been successfully deployed yet)
デプロイ環境をマッピングする
Deployment events include the name of the environment your app was deployed to. To show environment details in your Jira work items, Jira needs to know whether the environment is a development
, testing
, staging
, or production
environment. Jira tries to guess which environment to map your deployment event to based on the environment name. For example, a deployment to an environment named prod
would be considered a production
environment.
他の環境名(英語以外の環境名など)を使用すると、Jira はそれらを未定義の環境として表示します。これを解決するには、.jira/config.yml
というファイルをリポジトリのメイン・ブランチに追加し、カスタム環境名を Jira が認識する標準環境名にマッピングすることで、カスタム環境を指定できます。
例を以下に示します。
deployments:
environmentMapping:
development:
- "dev*"
- "Entwicklung"
- "desenvolvimento"
- "дев"
testing:
- "testes"
- "Test"
- "TST-*"
- "тест"
staging:
- "Pre-Prod"
- "STG-*"
- "staging"
production:
- "Produktion"
- "produção"
- "продакшн"
- "PROD-*"
上記の例を使用すると、「TST-3」という名前の環境へのデプロイ・イベントは、testing
環境へのデプロイとして Jira に表示されます。一方、「produção」という名前の環境へのデプロイは、production
環境として Jira に表示されます。
Jira の 4 つの有効な環境タイプのそれぞれに、最大 10 個の glob パターンを指定できます。この設定ファイルを追加すると Jira で環境名を自動的に検出できなくなるため、すべての環境名のパターンを指定する必要があります。
この内容はお役に立ちましたか?