Jenkins によるデプロイ の追跡を使用する
Changes to Jira Service Management Free and Standard
As of October 16, 2024, change management in Jira Service Management has moved from Standard to Premium. Existing service projects in Free and Standard will continue to support existing request types and work types. Read more about the plan changes.
To access Jira Service Management Premium features, subscribe to a Service Collection Premium or Enterprise plan.
Deployment tracking lets you automatically create or update a change request from any stage in your Jenkins pipeline. Use deployment tracking if approval from stakeholders isn’t required before changes occur. If you need approval from stakeholders, use deployment gating.
デプロイの追跡を使用するには、次の手順を実行する必要があります。
Jenkins によるデプロイの追跡を使用するには、次の手順を実行します。
Jenkinsfile に移動します。
Jira に通知したいパイプラインの段階を見つけます。
sendJiraDeploymentInfo ブロックを段階ステップに追加して、Jira Service Management プロジェクトからコピーした Jira サイト名、環境 ID、環境タイプ、サービス IDを置換します。
スニペットの例
stage('Production') {
steps {
// Notify Jira a new deployment has started
jiraSendDeploymentInfo (
environmentId: 'us-prod-1',
environmentName: 'us-prod-1',
environmentType: 'production',
serviceIds: [
'<YOUR-SERVICE-ID>'
],
site: '<YOUR-SITE>.atlassian.net',
state: 'in_progress'
)
sh 'echo Deploy to Production starting...'
}
post {
always {
sh 'sleep 2'
sh 'echo Deployment to production finished'
}
success {
echo 'Deployment successful'
// Notify Jira if the deployment succeeded
jiraSendDeploymentInfo (
environmentId: 'us-prod-1',
environmentName: 'us-prod-1',
environmentType: 'production',
serviceIds: [
'<YOUR-SERVICE-ID>'
],
site: '<YOUR-SITE>.atlassian.net',
state: 'successful'
)
}
failure {
echo 'Deployment failed'
// Notify Jira if the deployment succeeded
jiraSendDeploymentInfo (
environmentId: 'us-prod-1',
environmentName: 'us-prod-1',
environmentType: 'production',
serviceIds: [
'<YOUR-SERVICE-ID>'
],
site: '<YOUR-SITE>.atlassian.net',
state: 'failed'
)
}
}
}
}
完全な Jenkinsfile の例
本番へのデプロイが開始されたら Jira に通知し、デプロイが終了したらもう一度通知します。
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'echo Run build...'
}
}
stage('Test') {
steps {
sh 'echo Run tests...'
}
}
stage('Stage') {
steps {
sh 'echo Deploy to Staging...'
}
}
stage('Production') {
steps {
jiraSendDeploymentInfo (
environmentId: 'us-prod-1',
environmentName: 'us-prod-1',
environmentType: 'production',
serviceIds: [
'<YOUR-SERVICE-ID>'
],
site: '<YOUR-SITE>.atlassian.net',
state: 'in_progress'
)
sh 'echo Deploy to Production starting...'
}
post {
always {
sh 'sleep 2'
sh 'echo Deployment to production finished'
}
// Notify Jira based on deployment step result
success {
echo 'Deployment successful'
jiraSendDeploymentInfo (
environmentId: 'us-prod-1',
environmentName: 'us-prod-1',
environmentType: 'production',
serviceIds: [
'<YOUR-SERVICE-ID>'
],
site: '<YOUR-SITE>.atlassian.net',
state: 'successful'
)
}
failure {
echo 'Deployment failed'
jiraSendDeploymentInfo (
environmentId: 'us-prod-1',
environmentName: 'us-prod-1',
environmentType: 'production',
serviceIds: [
'<YOUR-SERVICE-ID>'
],
site: '<YOUR-SITE>.atlassian.net',
state: 'failed'
)
}
aborted {
echo 'Deployment cancelled'
jiraSendDeploymentInfo (
environmentId: 'us-prod-1',
environmentName: 'us-prod-1',
environmentType: 'production',
serviceIds: [
'<YOUR-SERVICE-ID>'
],
site: '<YOUR-SITE>.atlassian.net',
state: 'cancelled'
)
}
}
}
}
}
この内容はお役に立ちましたか?