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 5 years have passed since last update.

AzurePipelineでは環境変数を小文字で定義できない

Posted at

概要

Azure Pipelineを使っている時になぜか環境変数が取れなかったことがあって悩んだのでメモ

タイトルの通りだが、正確には定義できないわけではなく、勝手に内部で大文字に変換される

例えば、

trigger:
- none

variables:
  ci: "true"

pool:
  vmImage: 'Ubuntu-16.04'

steps:
- task: Maven@3
  inputs:
    ~~省略~~

こんなyamlを定義して、コード側で

private static boolean ci = "true".equals(System.getenv("ci"));

とかやっても取れない

こうやるのが正しい

trigger:
- none

variables:
  # must UPPER-CASE!!
  CI: "true" 

pool:
  vmImage: 'Ubuntu-16.04'

steps:
- task: Maven@3
  inputs:
    ~~省略~~
// must UPPER-CASE!!
private static boolean ci = "true".equals(System.getenv("CI"));

対策

設定も何も無いので環境変数は大文字で書かないといけない

おわりに

いや、ドキュメントに書けや!!

というか勝手に変換するならもう小文字環境変数には警告ログでいいだろ!!

......というのもそうだが、何よりコンソールの出力が全体的にunix風なので、Windows likeな大文字小文字を区別しない仕様が唐突に出てくると人は完全に騙される

こういう「人を騙す仕様」は反面教師としたい

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?