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

Issue 469 - Add options param to docker pull and docker push commands #470

Open
wants to merge 3 commits into
base: dev
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 jfrog-tasks-utils/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ declare module '@jfrog/tasks-utils' {
export function configureDefaultDistributionServer(usageType: string, cliPath: string, workDir: string): string;
export function taskDefaultCleanup(cliPath: string, workDir: string, serverIdsArray: string[]): string;
export function appendBuildFlagsToCliCommand(cliCommand: string): string;
export function appendOptionsToCliCommand(cliCommand: string): string;
export function isToolExists(tool: string): boolean;
export function removeExtractorsDownloadVariables(cliPath: string, workDir: string);
export function configureArtifactoryCliServer(artifactoryService: string, serverId: string, cliPath: string, buildDir: string);
Expand Down
12 changes: 12 additions & 0 deletions jfrog-tasks-utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ module.exports = {
createBuildToolConfigFile: createBuildToolConfigFile,
assembleUniqueServerId: assembleUniqueServerId,
appendBuildFlagsToCliCommand: appendBuildFlagsToCliCommand,
appendOptionsToCliCommand: appendOptionsToCliCommand,
compareVersions: compareVersions,
addTrailingSlashIfNeeded: addTrailingSlashIfNeeded,
useCliServer: useCliServer,
Expand Down Expand Up @@ -765,6 +766,17 @@ function appendBuildFlagsToCliCommand(cliCommand) {
return cliCommand;
}

/**
* Appends options param to provided cli command if command options not blank.
* */
function appendOptionsToCliCommand(cliCommand) {
let cmdOptions = tl.getInput('cmdOptions', true) ?? '';
if (cmdOptions != '') {
cliCommand = cliJoin(cliCommand, cmdOptions);
}
return cliCommand;
}

/**
* Returns the current timestamp in seconds
*/
Expand Down
5 changes: 4 additions & 1 deletion tasks/JFrogDocker/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ function RunTaskCbk(cliPath: string): void {
const command: string = tl.getInput('command', true) ?? '';
let cliCommand: string = utils.cliJoin(cliPath, cliDockerCommand, command.toLowerCase(), utils.quote(imageName));
switch (command) {
case 'Push':
case 'Push': {
cliCommand = utils.appendOptionsToCliCommand(cliCommand);
break;
}
case 'Pull': {
serverId = utils.configureDefaultArtifactoryServer('docker_' + command, cliPath, defaultWorkDir);
cliCommand = utils.appendBuildFlagsToCliCommand(cliCommand);
Expand Down
10 changes: 10 additions & 0 deletions tasks/JFrogDocker/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@
"required": true,
"groupName": "advanced",
"helpMarkDown": "Select if you'd like the command to skip performing docker login."
},
{
"name": "cmdOptions",
"type": "string",
"label": "Options",
"defaultValue": "",
"required": false,
"groupName": "advanced",
"visibleRule": "command != Scan",
"helpMarkDown": "Options for Pull and Push docker command."
}
],
"execution": {
Expand Down
1 change: 1 addition & 0 deletions tests/resources/docker/pull.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let inputs = {
command: 'Pull',
collectBuildInfo: true,
imageName: `${platformDockerDomain}/docker-local/docker-test:1`,
cmdOptions: `--all-tags`,
};

testUtils.runArtifactoryTask(testUtils.docker, {}, inputs);
1 change: 1 addition & 0 deletions tests/resources/docker/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let inputs = {
command: 'Push',
collectBuildInfo: true,
imageName: `${platformDockerDomain}/docker-local/docker-test:1`,
cmdOptions: ``,
};

testUtils.runArtifactoryTask(testUtils.docker, {}, inputs);
Loading