Jenkins によるデプロイのゲーティングを使用する
Jira Service Management の Free プランとスタンダードプランの変更
As of October 16, 2024, change management for Jira Service Management will move from Standard to Premium plans. After this point, only Premium and Enterprise plans will have access to this feature.
Free プランとスタンダードプランの既存のプロジェクトは、既存のリクエストタイプと課題タイプを引き続きサポートします。この変更の詳細についてはこちらをご確認ください。
デプロイのゲーティングを使用して、Jenkins パイプラインのいずれかの段階で承認ゲート付きの変更リクエストを作成します。パイプラインが変更リクエスト Jira ワークフローのステータスの使用を継続すべきかどうか (および、いつ継続すべきか) を制御します。関係者は、Jira Service Management からのデプロイを許可または阻止できます。
デプロイのゲーティングを使用するには、次の手順を実行する必要があります。
Jenkins によるデプロイ ゲーティングを使用するには、次の手順を実行します。
Jenkinsfile に移動します。
変更リクエストを起票したいパイプラインの段階を見つけます。たとえば、「本番」デプロイ段階前などです。
デプロイのエーティング用に、パイプラインに 2 つの段階を追加することをお勧めします。変更リクエストを発行する段階と、もう変更リクエストのステータスをチェックする段階です。
Add the following snippet to your pipeline, replacing your Jira site name, environment ID, environment type and service ID(s) you copied from your Jira Service Management project.
stage('Request approval') { // Raise change request
steps {
echo 'Raise change request...'
jiraSendDeploymentInfo(site:'<YOUR-SITE>.atlassian.net',
environmentId:'us-prod-1',
environmentName:'us-prod-1',
environmentType:'production',
state:"pending",
enableGating:true,
serviceIds: [
'<YOUR-SERVICE-ID>'
]
)
}
}
stage("Approval gate") { // Check request status
steps {
retry(20) { // Poll every 30s for 10min
waitUntil {
sleep 30
checkGatingStatus(
site:'<YOUR-SITE>.atlassian.net',
environmentId:'us-prod-1'
)
}
}
}
}
スニペットの例: ゲーティングされた変更リクエストを起票します
stage('Request approval') { // Raise change request
steps {
echo 'Raise change request...'
jiraSendDeploymentInfo(site:'<YOUR-SITE>.atlassian.net',
environmentId:'us-prod-1',
environmentName:'us-prod-1',
environmentType:'production',
state:"pending", // Deployment has not started yet
enableGating:true, // Notify Jira the pipeline is gated
serviceIds: [
'<YOUR-SERVICE-ID>'
]
)
}
}
スニペットの例: 変更リクエスト ステータスを手動でチェックします
stage("Approval gate") {
steps {
waitUntil {
input message: "Check for approval?" // Manually trigger check status
checkGatingStatus(
site:'<YOUR-SITE>.atlassian.net',
environmentId:'us-prod-1'
)
}
}
}
}
スニペットの例: 遅延後に自動的に変更リクエスト ステータスをチェックします
stage("Approval gate") {
steps {
waitUntil {
sleep 30 // check status after 30s
checkGatingStatus(
site:'<YOUR-SITE>.atlassian.net',
environmentId:'us-prod-1'
)
}
}
}
}
スニペットの例: 自動的に変更リクエスト ステータスをチェックします (ポーリング)
stage("Approval gate") {
steps {
retry(20) { // Retry every 30s for 10min
waitUntil {
sleep 30
checkGatingStatus(
site:'<YOUR-SITE>.atlassian.net',
environmentId:'us-prod-1'
)
}
}
}
}
完全な Jenkinsfile の例
変更リクエストを起票し、本番へのデプロイ前に承認を待ちます。承認が完了したら、自動的にパイプラインを再開します。
pipeline {
agent any
stages {
stage("Test") {
steps {
echo "Deploying to test"
}
}
stage("Stage") {
steps {
echo "Deploying to staging"
}
}
stage('Request approval') { // Raise change request
steps {
echo 'Raise change request...'
jiraSendDeploymentInfo(site:'<YOUR-SITE>.atlassian.net',
environmentId:'us-prod-1',
environmentName:'us-prod-1',
environmentType:'production',
state:"pending",
enableGating:true,
serviceIds: [
'<YOUR-SERVICE-ID>'
]
)
}
}
stage("Approval gate") { // Check change request status
steps {
retry(20) { // Poll every 30s for 10min
waitUntil {
sleep 30
checkGatingStatus(
site:'<YOUR-SITE>.atlassian.net',
environmentId:'us-prod-1'
)
}
}
}
}
stage("Production") {
steps {
echo "Deploying to production!!"
}
post {
always {
sh 'sleep 2'
}
// Notify Jira based on deployment step result
success {
jiraSendDeploymentInfo (
site: '<YOUR-SITE>.atlassian.net',
environmentId: 'us-prod-1',
environmentName: 'us-prod-1',
environmentType: 'production',
state: 'successful',
serviceIds: [
'<YOUR-SERVICE-ID>'
]
)
}
}
}
}
}
この内容はお役に立ちましたか?