adding an option to remove image after publish
This commit is contained in:
Родитель
aa7d17c9e7
Коммит
d1ee16cfc7
|
@ -40,6 +40,9 @@ export class DockerCommand {
|
|||
case "logout":
|
||||
this.appendLogoutCmdArgs(command);
|
||||
break;
|
||||
case "removeImage":
|
||||
this.appendRemoveImageCmdArgs(command);
|
||||
break;
|
||||
default:
|
||||
command.arg(this.commandName);
|
||||
}
|
||||
|
@ -121,4 +124,8 @@ export class DockerCommand {
|
|||
private appendLogoutCmdArgs(command: tr.ToolRunner) {
|
||||
command.arg("logout");
|
||||
}
|
||||
|
||||
private appendRemoveImageCmdArgs(command: tr.ToolRunner) {
|
||||
command.arg("rmi --force " + this.imageName);
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ export function dockerPublish(): void {
|
|||
var dockerConnectionString = tl.getInput("dockerServiceEndpoint", true);
|
||||
var registryEndpoint = tl.getInput("dockerRegistryServiceEndpoint", true);
|
||||
var imageName = tl.getInput("imageName", true);
|
||||
var removeImageAfterPublish = tl.getBoolInput("removeImageAfterPublish", true);
|
||||
var additionalArgs = tl.getInput("additionalArgs", false);
|
||||
|
||||
var registryConnetionDetails = tl.getEndpointAuthorization(registryEndpoint, true);
|
||||
|
@ -22,6 +23,13 @@ export function dockerPublish(): void {
|
|||
publishCmd.additionalArguments = additionalArgs;
|
||||
publishCmd.execSync();
|
||||
|
||||
if (removeImageAfterPublish) {
|
||||
var rmiCmd = new docker.DockerCommand("removeImage");
|
||||
rmiCmd.dockerConnectionString = dockerConnectionString;
|
||||
rmiCmd.imageName = imageName;
|
||||
rmiCmd.execSync();
|
||||
}
|
||||
|
||||
var logoutCmd = new docker.DockerCommand("logout");
|
||||
logoutCmd.dockerConnectionString = dockerConnectionString;
|
||||
logoutCmd.execSync();
|
||||
|
|
|
@ -71,6 +71,14 @@
|
|||
"required": "true",
|
||||
"helpMarkDown": "name of the image to run"
|
||||
},
|
||||
{
|
||||
"name": "removeImageAfterPublish",
|
||||
"type": "boolean",
|
||||
"label": "Remove image after publish",
|
||||
"defaultValue": "false",
|
||||
"visibleRule": "action = publish image",
|
||||
"helpMarkDown": "When true the image is force removed after publishing."
|
||||
},
|
||||
{
|
||||
"name": "additionalArgs",
|
||||
"type": "string",
|
||||
|
|
Загрузка…
Ссылка в новой задаче