diff --git a/src/tasks/dockerRun/dockerCommand.ts b/src/tasks/dockerRun/dockerCommand.ts index ad1fba2..7b51b59 100644 --- a/src/tasks/dockerRun/dockerCommand.ts +++ b/src/tasks/dockerRun/dockerCommand.ts @@ -12,6 +12,7 @@ export class DockerCommand { public context: string; public imageName: string; public containerName: string; + public envVars: string[]; public additionalArguments: string; public dockerConnectionString: string; public registryConnetionDetails: tl.EndpointAuthorization; @@ -103,6 +104,11 @@ export class DockerCommand { private appendRunCmdArgs(command: tr.ToolRunner) { command.arg("run"); + if (this.envVars) { + this.envVars.forEach(function (v, i) { + command.arg("-e " + v); + }); + } if (this.containerName) { command.arg("--name " + this.containerName); } diff --git a/src/tasks/dockerRun/dockerRun.ts b/src/tasks/dockerRun/dockerRun.ts index 884e78d..11d20b3 100644 --- a/src/tasks/dockerRun/dockerRun.ts +++ b/src/tasks/dockerRun/dockerRun.ts @@ -8,6 +8,7 @@ export function dockerRun(): void { var registryEndpoint = tl.getInput("dockerRegistryServiceEndpoint", true); var imageName = tl.getInput("imageName", true); var containerName = tl.getInput("containerName", false); + var envVars = tl.getDelimitedInput("envVars", "\n", false); var additionalArgs = tl.getInput("additionalArgs", false); var registryConnetionDetails = tl.getEndpointAuthorization(registryEndpoint, true); @@ -22,9 +23,10 @@ export function dockerRun(): void { } var cmd = new docker.DockerCommand("run"); + cmd.dockerConnectionString = dockerConnectionString; cmd.imageName = imageName; cmd.containerName = containerName; - cmd.dockerConnectionString = dockerConnectionString; + cmd.envVars = envVars; cmd.additionalArguments = additionalArgs; cmd.execSync(); diff --git a/src/tasks/dockerRun/task.json b/src/tasks/dockerRun/task.json index d15bfcc..ab1a11b 100644 --- a/src/tasks/dockerRun/task.json +++ b/src/tasks/dockerRun/task.json @@ -80,6 +80,15 @@ "visibleRule": "action = run a container", "helpMarkDown": "Name to use for Docker container." }, + { + "name": "envVars", + "type": "multiLine", + "label": "Environment Variables", + "defaultValue": "", + "required": false, + "visibleRule": "action = run a container", + "helpMarkDown": "Name value pairs to pass as environments variables to the run commnad in name=value format." + }, { "name": "removeImageAfterPublish", "type": "boolean",