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 DevOps】ACRにPushするコンテナタグにコミットハッシュを指定する

Last updated at Posted at 2022-08-29

Azure DevOpsで成果物であるコンテナをACRにPushし、Webapp for Containerへデプロイするパイプラインを作成しました。
その際、ACRのコンテナタグを一意にするため、コミットハッシュを使いたかたったのですが、情報があまりなかったので手順を残しておきます。

ベースとなるDevOpsの設定や、WebAppについてはこちらの記事を参照

yamlを修正

tagを$(Build.SourceVersion)に変更
$(Build.SourceVersion)はPipelineがトリガーされたgit commitのハッシュを参照する変数です
image.png

Releasesを修正

Pipelineを変更しただけではACRにPushするところまでですので、実際にどのtagをデプロイするか管理しているReleasesも修正する必要があります
Releasesでも同じく$(Build.SourceVersion)が利用できます

Azure App Service deployのTask内でtagを指定している箇所があるので、ここを$(Build.SourceVersion)に置き換えます
image.png

動作確認

ACRにコミットハッシュでイメージがPushされており、WebAppが更新されていればOKです
image.png

雑感

$(Build.SourceVersion)で参照できるハッシュが長いのでShort Hash(8桁)で利用できる方法があればなお良し

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?