Skip to content

Commit af6d484

Browse files
authored
Logging only the primary action being performed when custom command is run via Docker V0 task (#8560) (#8566)
1 parent 2ebccd0 commit af6d484

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

Tasks/DockerV0/container.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,36 @@ connection.open(tl.getInput("dockerHostEndpoint"), registryAuthenticationToken);
3232

3333
// Run the specified action
3434
var action = tl.getInput("action", true);
35+
let command = "";
36+
37+
if(action !== "run a docker command") {
38+
command = action;
39+
}
40+
else {
41+
let customCommand = tl.getInput("customCommand", true);
42+
43+
// sanitize the custom command parameters to log just the action
44+
let commandTokens = customCommand.split(" ");
45+
if(commandTokens.length > 0) {
46+
for(let index = 0; index < commandTokens.length; index ++) {
47+
// Stop reading tokens when we see any that starts with a special character
48+
if(/^[a-z0-9A-Z]/i.test(commandTokens[index])) {
49+
command = command + commandTokens[index] + " ";
50+
}
51+
else{
52+
break;
53+
}
54+
}
55+
command = command.trim();
56+
}
57+
else {
58+
command = "run a docker command"
59+
}
60+
}
61+
3562
var telemetry = {
3663
registryType: registryType,
37-
command: action !== "Run a Docker command" ? action : tl.getInput("customCommand", true)
64+
command: command
3865
};
3966

4067
console.log("##vso[telemetry.publish area=%s;feature=%s]%s",

Tasks/DockerV0/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"version": {
1414
"Major": 0,
1515
"Minor": 3,
16-
"Patch": 18
16+
"Patch": 19
1717
},
1818
"demands": [],
1919
"preview": "false",

0 commit comments

Comments
 (0)