Azure Pipelines: Azure DevOps では、パイプライン完了トリガーは使えないので、マルチステージパイプラインで対処

# 背景

パイプライン yaml を 単純に保とうと思ってたら、どうやっても trigger が反応せず・・

で、調べたら、YAML テンプレートではまだ未対応とかいう落ち :sweat: 

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/120072/c8a8827b-069e-12d1-3f4d-25ebd0efd4c3.png)

https://learn.microsoft.com/ja-jp/azure/devops/pipelines/process/pipeline-triggers?view=azure-devops

ここでは使えるように書いてるから試してたのに！！！
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/120072/30eefae5-31e8-470b-709b-fc218155579f.png)


https://learn.microsoft.com/ja-jp/azure/devops/pipelines/build/triggers?view=azure-devops#branch-consideration-for-triggers-in-yaml-pipelines

# 解決策

単一 Yaml に全てまとめて、それぞれを stage として実装する。
いわゆる、マルチステージパイプライン化すれば解決

```yaml: Multi Stage Pipeline
trigger:
- '*'

variables:
  buildConfiguration: 'Release'
  releaseBranchName: 'release'

stages:
- stage: 'Build'
  displayName: 'Build the web application'
  jobs: 
  - job: 'Build'
    displayName: 'Build job'
    pool:
      vmImage: 'ubuntu-20.04'
      demands:
      - npm

    variables:
      wwwrootDir: 'Tailspin.SpaceGame.Web/wwwroot'
      dotnetSdkVersion: '6.x'

    steps:
    - task: UseDotNet@2
      displayName: 'Use .NET SDK $(dotnetSdkVersion)'
      inputs:
        version: '$(dotnetSdkVersion)'

    - task: Npm@1
      displayName: 'Run npm install'
      inputs:
        verbose: false

    - script: './node_modules/.bin/node-sass $(wwwrootDir) --output $(wwwrootDir)'
      displayName: 'Compile Sass assets'

    - task: gulp@1
      displayName: 'Run gulp tasks'

    - script: 'echo "$(Build.DefinitionName), $(Build.BuildId), $(Build.BuildNumber)" > buildinfo.txt'
      displayName: 'Write build info'
      workingDirectory: $(wwwrootDir)

    - task: DotNetCoreCLI@2
      displayName: 'Restore project dependencies'
      inputs:
        command: 'restore'
        projects: '**/*.csproj'

    - task: DotNetCoreCLI@2
      displayName: 'Build the project - $(buildConfiguration)'
      inputs:
        command: 'build'
        arguments: '--no-restore --configuration $(buildConfiguration)'
        projects: '**/*.csproj'

    - task: DotNetCoreCLI@2
      displayName: 'Publish the project - $(buildConfiguration)'
      inputs:
        command: 'publish'
        projects: '**/*.csproj'
        publishWebProjects: false
        arguments: '--no-build --configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)/$(buildConfiguration)'
        zipAfterPublish: true

    - publish: '$(Build.ArtifactStagingDirectory)'
      artifact: drop

- stage: 'Dev'
  displayName: 'Deploy to the dev environment'
  dependsOn: Build
  condition:  succeeded()
  jobs:
  - deployment: Deploy
    pool:
      vmImage: 'ubuntu-20.04'
    environment: dev
    variables:
    - group: Release
    strategy:
      runOnce:
        deploy:
          steps:
          - download: current
            artifact: drop
          - task: AzureWebApp@1
            displayName: 'Azure App Service Deploy: dev website'
            inputs:
              azureSubscription: 'your-subscription'
              appType: 'webAppLinux'
              appName: '$(WebAppNameDev)'
              package: '$(Pipeline.Workspace)/drop/$(buildConfiguration)/*.zip'
```

https://learn.microsoft.com/ja-jp/azure/devops/pipelines/process/create-multistage-pipeline?view=azure-devops

# あとがき

classic pipeline は deprecate されそうだったんで、yaml を選んだわけだけど、
GitHub Actions では対応してても、Azure Repos では非対応とかもあって、なんか散々だ・・ :sweat: