From b21587446bb06e0bde1a147943bfa27fd3f532f7 Mon Sep 17 00:00:00 2001 From: Bryan Oltman Date: Fri, 22 Mar 2024 12:45:43 -0400 Subject: [PATCH] fix(shorebird_cli): detect Azure pipeline CI environment --- packages/shorebird_cli/lib/src/shorebird_env.dart | 6 +++++- packages/shorebird_cli/test/src/shorebird_env_test.dart | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/shorebird_cli/lib/src/shorebird_env.dart b/packages/shorebird_cli/lib/src/shorebird_env.dart index 372a95f66..560067924 100644 --- a/packages/shorebird_cli/lib/src/shorebird_env.dart +++ b/packages/shorebird_cli/lib/src/shorebird_env.dart @@ -230,5 +230,9 @@ class ShorebirdEnv { // https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables || - platform.environment.containsKey('GITHUB_ACTIONS'); + platform.environment.containsKey('GITHUB_ACTIONS') + + // https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml + || + platform.environment.containsKey('TF_BUILD'); } diff --git a/packages/shorebird_cli/test/src/shorebird_env_test.dart b/packages/shorebird_cli/test/src/shorebird_env_test.dart index 11d332735..bbe61775a 100644 --- a/packages/shorebird_cli/test/src/shorebird_env_test.dart +++ b/packages/shorebird_cli/test/src/shorebird_env_test.dart @@ -607,6 +607,11 @@ base_url: https://example.com'''); expect(runWithOverrides(() => shorebirdEnv.isRunningOnCI), isTrue); }); + test('returns true if TF_BUILD is set', () { + when(() => platform.environment).thenReturn({'TF_BUILD': 'True'}); + expect(runWithOverrides(() => shorebirdEnv.isRunningOnCI), isTrue); + }); + test('returns false if no relevant environment variables are set', () { when(() => platform.environment).thenReturn({}); expect(runWithOverrides(() => shorebirdEnv.isRunningOnCI), isFalse);