Skip to content

Provide option to specify arguments for container jobs and services #1152

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/Runner.Worker/Container/ContainerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public ContainerInfo(IHostContext hostContext, Pipelines.JobContainer container,
this.ContainerImage = containerImage;
this.ContainerDisplayName = $"{container.Alias}_{Pipelines.Validation.NameValidation.Sanitize(containerImage)}_{Guid.NewGuid().ToString("N").Substring(0, 6)}";
this.ContainerCreateOptions = container.Options;
this.ContainerEntryPointArgs = string.Join(" ", container.Args);
_environmentVariables = container.Environment;
this.IsJobContainer = isJobContainer;
this.ContainerNetworkAlias = networkAlias;
Expand Down
9 changes: 9 additions & 0 deletions src/Sdk/DTPipelines/Pipelines/JobContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ public IList<String> Ports
set;
}

/// <summary>
/// Gets or sets the arguments used for the container instance.
/// </summary>
public IList<String> Args
{
get;
set;
}

/// <summary>
/// Gets or sets the credentials used for pulling the container iamge.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ namespace GitHub.DistributedTask.Pipelines.ObjectTemplating
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class PipelineTemplateConstants
{
public const String Args = "args";
public const String Always = "always";
public const String BooleanStepsContext = "boolean-steps-context";
public const String BooleanStrategyContext = "boolean-strategy-context";
public const String CancelTimeoutMinutes = "cancel-timeout-minutes";
public const String Cancelled = "cancelled";
public const String Clean= "clean";
public const String Clean = "clean";
public const String Container = "container";
public const String ContinueOnError = "continue-on-error";
public const String Credentials = "credentials";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,17 @@ internal static JobContainer ConvertToJobContainer(
case PipelineTemplateConstants.Credentials:
result.Credentials = ConvertToContainerCredentials(containerPropertyPair.Value);
break;
case PipelineTemplateConstants.Args:
var args = containerPropertyPair.Value.AssertSequence($"{PipelineTemplateConstants.Container} {propertyName}");
var argList = new List<String>(args.Count);
foreach (var argItem in args)
{
var argString = argItem.AssertString($"{PipelineTemplateConstants.Container} {propertyName} {argItem.ToString()}").Value;
argList.Add(argString);
}
result.Args = argList;
break;

default:
propertyName.AssertUnexpectedValue($"{PipelineTemplateConstants.Container} key");
break;
Expand Down