メインコンテンツまでスキップ

Azure Pipeline (マスターブランチ)

masterブランチのプッシュとPRビルドを担当するAzure DevOpsパイプラインです。 ビルド後にSonarQubeによる静的分析を実行し、合格した場合はACRにイメージをプッシュします。

パイプラインのリスト

パイプラインYAMLファイルトリガー
infolineage-apiinfra/azure-pipelines/pipelines/api-pipeline.ymlmaster push / PR
infolineage-workerinfra/azure-pipelines/pipelines/worker-pipeline.ymlmaster push / PR
infolineage-frontendinfra/azure-pipelines/pipelines/frontend-pipeline.ymlmaster push / PR

YAML構造

infra/azure-pipelines/
├── pipelines/
│ ├── api-pipeline.yml ← 각 모듈 진입점
│ ├── worker-pipeline.yml
│ └── frontend-pipeline.yml
└── templates/
├── build-java.yml ← Gradle 빌드 템플릿
├── sonar-scan.yml ← SonarQube 분석 템플릿
└── docker-push.yml ← Docker 빌드 & ACR 푸시 템플릿

パイプライン YAML はtemplates/template参照として再利用します。

# 예시: api-pipeline.yml
stages:
- stage: Build
jobs:
- template: ../templates/build-java.yml
parameters:
module: infolineage-api

- stage: SonarQube
jobs:
- template: ../templates/sonar-scan.yml
parameters:
projectKey: infolineage-api

- stage: Docker
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
jobs:
- template: ../templates/docker-push.yml
parameters:
module: api

トリガー戦略

trigger:
branches:
include:
- master

pr:
branches:
include:
- master
  • master push: 3ステップすべて実行 (Build → SonarQube → Docker)
  • PRビルド: Build + SonarQubeのみ実行し、Dockerプッシュはスキップします (condition: eq(variables['Build.SourceBranch'], 'refs/heads/master'))

3段階のフロー

Stage 1: Build

- task: Gradle@3
inputs:
gradleWrapperFile: 'backend/gradlew'
workingDirectory: 'backend'
tasks: ':infolineage-api:bootJar -x test --build-cache'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '25'
options: '-Dorg.gradle.jvmargs="--enable-preview -Xmx2g"'

Stage 2: SonarQube

- task: SonarQubePrepare@5
inputs:
SonarQube: 'SonarQube' # Service Connection 이름
scannerMode: 'Other'
extraProperties: |
sonar.projectKey=infolineage-api
sonar.sources=backend/infolineage-api/src/main
sonar.tests=backend/infolineage-api/src/test
sonar.java.binaries=backend/infolineage-api/build/classes
sonar.java.source=25

- task: SonarQubeAnalyze@5

- task: SonarQubePublish@5
inputs:
pollingTimeoutSec: '300'

Stage 3: Docker → ACR

- task: Docker@2
inputs:
containerRegistry: 'AzureContainerRegistry'
repository: 'infolineage/api'
command: 'buildAndPush'
Dockerfile: 'backend/infolineage-api/Dockerfile'
buildContext: 'backend'
tags: 'latest'

サービス接続のリスト

名前タイプ用途
SonarQubeSonarQubeSonarQube分析サーバー接続
AzureContainerRegistryDocker RegistryACR イメージプッシュ

Azure DevOps → プロジェクト設定 → サービス接続で管理します。

今後の計画

ステップ内容状態
ステージング自動デプロイDocker Stage 後 K8s ステージング自動ロールアウト未実装
Production 手動承認Azure DevOps 承認ゲート + 手動デプロイ未実装
path triggerモノレポのパスフィルターで変更されたモジュールのみをビルド未実装