diff --git a/src/Agent.Sdk/Knob/AgentKnobs.cs b/src/Agent.Sdk/Knob/AgentKnobs.cs index de5f3894b0..224370922b 100644 --- a/src/Agent.Sdk/Knob/AgentKnobs.cs +++ b/src/Agent.Sdk/Knob/AgentKnobs.cs @@ -499,7 +499,13 @@ public class AgentKnobs new EnvironmentKnobSource("AZP_AGENT_CLEANUP_PSMODULES_IN_POWERSHELL"), new BuiltInDefaultKnobSource("false")); - public static readonly Knob IgnoreVSTSTaskLib = new Knob( + public static readonly Knob DisableCleanRepoDefaultValue = new DeprecatedKnob( + nameof(DisableCleanRepoDefaultValue), + "Avoid to set default value if build.repository.clean variable is not set on Trigger Yaml UI or in checkout steps yaml config", + new EnvironmentKnobSource("AGENT_DISABLE_CLEAN_REPO_DEFAULT_VALUE"), + new BuiltInDefaultKnobSource("false")); + + public static readonly Knob IgnoreVSTSTaskLib = new Knob( nameof(IgnoreVSTSTaskLib), "Ignores the VSTSTaskLib folder when copying tasks.", new RuntimeKnobSource("AZP_AGENT_IGNORE_VSTSTASKLIB"), diff --git a/src/Agent.Worker/Build/BuildJobExtension.cs b/src/Agent.Worker/Build/BuildJobExtension.cs index de5ac9d9f6..cbc1fcecd1 100644 --- a/src/Agent.Worker/Build/BuildJobExtension.cs +++ b/src/Agent.Worker/Build/BuildJobExtension.cs @@ -8,6 +8,7 @@ using System.IO; using System.Linq; using Microsoft.TeamFoundation.DistributedTask.Pipelines; +using Agent.Sdk.Knob; namespace Microsoft.VisualStudio.Services.Agent.Worker.Build { @@ -257,9 +258,18 @@ private void UpdateCheckoutTasksAndVariables(IExecutionContext executionContext, executionContext.SetVariable(Constants.Variables.Build.RepoGitSubmoduleCheckout, submoduleCheckout.Value.ToString()); } - if (repoCleanFromSelf.HasValue) + // This condition is for maintaining backward compatibility. + // Remove the if-else condition and keep only the context inside the 'else' to set the default value in future releases. + if (AgentKnobs.DisableCleanRepoDefaultValue.GetValue(UtilKnobValueContext.Instance()).AsBoolean()) { - executionContext.SetVariable(Constants.Variables.Build.RepoClean, repoCleanFromSelf.Value.ToString()); + if (repoCleanFromSelf.HasValue) + { + executionContext.SetVariable(Constants.Variables.Build.RepoClean, repoCleanFromSelf.Value.ToString()); + } + } + else + { + executionContext.SetVariable(Constants.Variables.Build.RepoClean, repoCleanFromSelf.HasValue ? repoCleanFromSelf.Value.ToString() : "False"); } }