Skip to content

Commit 4dd344e

Browse files
Copilotdavidfowl
andcommitted
Move CI environment variables array to static readonly field
Co-authored-by: davidfowl <[email protected]>
1 parent 175947c commit 4dd344e

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/Aspire.Cli/Utils/CliHostEnvironment.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ internal interface ICliHostEnvironment
3131
/// </summary>
3232
internal sealed class CliHostEnvironment : ICliHostEnvironment
3333
{
34+
// Common CI environment variables
35+
// https://github.com/watson/ci-info/blob/master/vendors.json
36+
private static readonly string[] s_ciEnvironmentVariables =
37+
[
38+
"CI", // Generic CI indicator
39+
"GITHUB_ACTIONS",
40+
"AZURE_PIPELINES",
41+
"TF_BUILD", // Azure Pipelines alternative
42+
"JENKINS_URL",
43+
"GITLAB_CI",
44+
"CIRCLECI",
45+
"TRAVIS",
46+
"BUILDKITE",
47+
"APPVEYOR",
48+
"TEAMCITY_VERSION",
49+
"BITBUCKET_BUILD_NUMBER",
50+
"CODEBUILD_BUILD_ID", // AWS CodeBuild
51+
];
52+
3453
/// <summary>
3554
/// Gets whether the host supports interactive input (e.g., prompts, user input).
3655
/// </summary>
@@ -118,26 +137,7 @@ private static bool DetectAnsiSupport(IConfiguration configuration)
118137

119138
private static bool IsCI(IConfiguration configuration)
120139
{
121-
// Check for common CI environment variables
122-
// https://github.com/watson/ci-info/blob/master/vendors.json
123-
var ciEnvVars = new[]
124-
{
125-
"CI", // Generic CI indicator
126-
"GITHUB_ACTIONS",
127-
"AZURE_PIPELINES",
128-
"TF_BUILD", // Azure Pipelines alternative
129-
"JENKINS_URL",
130-
"GITLAB_CI",
131-
"CIRCLECI",
132-
"TRAVIS",
133-
"BUILDKITE",
134-
"APPVEYOR",
135-
"TEAMCITY_VERSION",
136-
"BITBUCKET_BUILD_NUMBER",
137-
"CODEBUILD_BUILD_ID", // AWS CodeBuild
138-
};
139-
140-
foreach (var envVar in ciEnvVars)
140+
foreach (var envVar in s_ciEnvironmentVariables)
141141
{
142142
var value = configuration[envVar];
143143
if (!string.IsNullOrEmpty(value))

0 commit comments

Comments
 (0)