adding environment variables input in docker run action
This commit is contained in:
Родитель
b67664ec04
Коммит
e2f0cf1dc6
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
Загрузка…
Ссылка в новой задаче