Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

action inputs allows expressions #5

Merged
merged 2 commits into from
May 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Agent.Listener/Agent.Listener.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.4.0" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.4.0" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.4.0" />
<PackageReference Include="vss-api-netcore" Version="0.5.113-private" />
<PackageReference Include="vss-api-netcore" Version="0.5.114-private" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand Down
2 changes: 1 addition & 1 deletion src/Agent.PluginHost/Agent.PluginHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
<PackageReference Include="vss-api-netcore" Version="0.5.113-private" />
<PackageReference Include="vss-api-netcore" Version="0.5.114-private" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand Down
2 changes: 1 addition & 1 deletion src/Agent.Plugins/Agent.Plugins.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="vss-api-netcore" Version="0.5.113-private" />
<PackageReference Include="vss-api-netcore" Version="0.5.114-private" />
<PackageReference Include="azuredevops-testresultparser" Version="1.0.1" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Agent.Sdk/Agent.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="vss-api-netcore" Version="0.5.113-private" />
<PackageReference Include="vss-api-netcore" Version="0.5.114-private" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.4.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.4.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Agent.Worker/Agent.Worker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="vss-api-netcore" Version="0.5.113-private" />
<PackageReference Include="vss-api-netcore" Version="0.5.114-private" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.4.0" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.4.0" />
</ItemGroup>
Expand Down
53 changes: 14 additions & 39 deletions src/Agent.Worker/JobExtensionRunner.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Threading.Tasks;
using Microsoft.TeamFoundation.DistributedTask.Expressions;
using Microsoft.TeamFoundation.DistributedTask.Pipelines.ObjectTemplating;
using Microsoft.VisualStudio.Services.Agent.Util;
using Pipelines = Microsoft.TeamFoundation.DistributedTask.Pipelines;
using Microsoft.VisualStudio.Services.Agent.Worker.Container;
Expand Down Expand Up @@ -142,35 +143,24 @@ public async Task RunAsync()
}
}

// Load the default input values from the definition.
Trace.Verbose("Loading default inputs.");
var inputs = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

// Load the inputs.
ExecutionContext.Output($"{WellKnownTags.Debug}Loading inputs");
var templateTrace = ExecutionContext.ToTemplateTraceWriter();
var schema = new PipelineTemplateSchemaFactory().CreateSchema();
var templateEvaluator = new PipelineTemplateEvaluator(templateTrace, schema);
var inputs = templateEvaluator.EvaluateStepInputs(Action.Inputs, ExecutionContext.ExpressionValues);

// Merge the default inputs from the definition
foreach (var input in (definition.Data?.Inputs ?? new TaskInputDefinition[0]))
{
string key = input?.Name?.Trim() ?? string.Empty;
if (!string.IsNullOrEmpty(key))
string key = input.Name?.Trim();
if (!string.IsNullOrEmpty(key) && !inputs.ContainsKey(key))
{
inputs[key] = input.DefaultValue?.Trim() ?? string.Empty;
}
}

// Merge the instance inputs.
Trace.Verbose("Loading instance inputs.");
foreach (var input in (Action.Inputs as IEnumerable<KeyValuePair<string, string>> ?? new KeyValuePair<string, string>[0]))
{
string key = input.Key?.Trim() ?? string.Empty;
if (!string.IsNullOrEmpty(key))
{
inputs[key] = input.Value?.Trim() ?? string.Empty;
}
}

// Expand the inputs.
Trace.Verbose("Expanding inputs.");
// runtimeVariables.ExpandValues(target: inputs);
// VarUtil.ExpandEnvironmentVariables(HostContext, target: inputs);


// Translate the server file path inputs to local paths.
foreach (var input in definition.Data?.Inputs ?? new TaskInputDefinition[0])
{
Expand All @@ -182,24 +172,9 @@ public async Task RunAsync()
}
}


// Load the task environment.
Trace.Verbose("Loading task environment.");
var environment = new Dictionary<string, string>(VarUtil.EnvironmentVariableKeyComparer);
foreach (var env in (Action.Environment ?? new Dictionary<string, string>(0)))
{
string key = env.Key?.Trim() ?? string.Empty;
if (!string.IsNullOrEmpty(key))
{
environment[key] = env.Value?.Trim() ?? string.Empty;
}
}


// Expand the environments.
Trace.Verbose("Expanding task environment.");
// runtimeVariables.ExpandValues(target: environment);
// VarUtil.ExpandEnvironmentVariables(HostContext, target: environment);
ExecutionContext.Output($"{WellKnownTags.Debug}Loading env");
var environment = templateEvaluator.EvaluateStepEnvironment(Action.Environment, ExecutionContext.ExpressionValues, VarUtil.EnvironmentVariableKeyComparer);

// Create the handler.
IHandler handler = handlerFactory.Create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.4.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.4.0" />
<PackageReference Include="vss-api-netcore" Version="0.5.113-private" />
<PackageReference Include="vss-api-netcore" Version="0.5.114-private" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand Down
2 changes: 1 addition & 1 deletion src/Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<PackageReference Include="System.Buffers" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.4.0" />
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
<PackageReference Include="vss-api-netcore" Version="0.5.113-private" />
<PackageReference Include="vss-api-netcore" Version="0.5.114-private" />
<PackageReference Include="Moq" Version="4.6.36-alpha" />
<PackageReference Include="azuredevops-testresultparser" Version="1.0.1" />
</ItemGroup>
Expand Down