0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Azure Pipelines 内から Azure CLI でプルリクを作ってみた

0
Posted at

例えば develop ブランチのパイプラインが全て通ったら main ブランチにプルリクを出す運用ルールだったとします。手動でプルリクを出しているくらいなら、自動化しても良いんじゃないかと思い、develop ブランチのパイプラインの一番最後に Azure CLI でプルリクを作成するタスクを組み込んでみました。

パイプライン例

Azure CLI でプルリクを行う前提として Service Connection にサービスプリンシパルを登録済みで、そのサービスプリンシパルがプロジェクトのメンバーになっている必要があります。

azure-pipelines.yml
trigger:
- develop

pool:
  vmImage: ubuntu-latest

steps:
- script: echo $(Build.BuildNumber)
- task: AzureCLI@2
  inputs:
    azureSubscription: 'mnrpoc'
    scriptType: 'bash'
    scriptLocation: 'inlineScript'
    inlineScript: |
      az repos pr create \
        --organization https://dev.azure.com/mnrsdev \
        --project mnrpoc \
        --repository mnrpoc \
        --source-branch develop \
        --target-branch main \
        --title "Pipeline Completed $(Build.BuildNumber)"

実行結果のプルリク

pipeline-completed.png

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?