Skip to content

Commit

Permalink
Modify the SshV0 task to direct the output to process.stdout instead …
Browse files Browse the repository at this point in the history
…of the console.log (#20507)

* Trim SshV0 task output newlines

* Change trimming to direct writing to process stdout
  • Loading branch information
ivanduplenskikh authored Oct 8, 2024
1 parent 76ccc08 commit e606f44
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 22 deletions.
12 changes: 10 additions & 2 deletions Tasks/SshV0/ssh2helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ export function runCommandOnRemoteMachine(
}).on('data', (data) => {
if (data) {
// "data" can be a buffer. Format it here so it outputs as a string
console.log(data.toString('utf8'));
if (tl.getPipelineFeature("redirectTaskOutputToProcessStdout")) {
process.stdout.write(data);
} else {
console.log(data.toString('utf8'));
}
if (!passwordSent) {
passwordSent = handlePasswordInput(data, stream, password, dataBuffer);
if (passwordSent) {
Expand All @@ -174,7 +178,11 @@ export function runCommandOnRemoteMachine(
}).on('data', (data) => {
if (data) {
// "data" can be a buffer. Format it here so it outputs as a string
console.log(data.toString('utf8'));
if (tl.getPipelineFeature("redirectTaskOutputToProcessStdout")) {
process.stdout.write(data);
} else {
console.log(data.toString('utf8'));
}
}
}).stderr.on('data', (data) => {
stdErrWritten = true;
Expand Down
2 changes: 1 addition & 1 deletion Tasks/SshV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 245,
"Minor": 247,
"Patch": 0
},
"demands": [],
Expand Down
2 changes: 1 addition & 1 deletion Tasks/SshV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 245,
"Minor": 247,
"Patch": 0
},
"demands": [],
Expand Down
4 changes: 2 additions & 2 deletions _generated/SshV0.versionmap.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Default|0.245.0
Node20-225|0.245.1
Default|0.247.0
Node20-225|0.247.1
12 changes: 10 additions & 2 deletions _generated/SshV0/ssh2helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ export function runCommandOnRemoteMachine(
}).on('data', (data) => {
if (data) {
// "data" can be a buffer. Format it here so it outputs as a string
console.log(data.toString('utf8'));
if (tl.getPipelineFeature("redirectTaskOutputToProcessStdout")) {
process.stdout.write(data);
} else {
console.log(data.toString('utf8'));
}
if (!passwordSent) {
passwordSent = handlePasswordInput(data, stream, password, dataBuffer);
if (passwordSent) {
Expand All @@ -174,7 +178,11 @@ export function runCommandOnRemoteMachine(
}).on('data', (data) => {
if (data) {
// "data" can be a buffer. Format it here so it outputs as a string
console.log(data.toString('utf8'));
if (tl.getPipelineFeature("redirectTaskOutputToProcessStdout")) {
process.stdout.write(data);
} else {
console.log(data.toString('utf8'));
}
}
}).stderr.on('data', (data) => {
stdErrWritten = true;
Expand Down
6 changes: 3 additions & 3 deletions _generated/SshV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 245,
"Minor": 247,
"Patch": 0
},
"demands": [],
Expand Down Expand Up @@ -165,7 +165,7 @@
"ScriptArgsSanitized": "Detected characters in arguments that may not be executed correctly by the shell. Please escape special characters using backslash (\\). More information is available here: https://aka.ms/ado/75787"
},
"_buildConfigMapping": {
"Default": "0.245.0",
"Node20-225": "0.245.1"
"Default": "0.247.0",
"Node20-225": "0.247.1"
}
}
6 changes: 3 additions & 3 deletions _generated/SshV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 245,
"Minor": 247,
"Patch": 0
},
"demands": [],
Expand Down Expand Up @@ -165,7 +165,7 @@
"ScriptArgsSanitized": "ms-resource:loc.messages.ScriptArgsSanitized"
},
"_buildConfigMapping": {
"Default": "0.245.0",
"Node20-225": "0.245.1"
"Default": "0.247.0",
"Node20-225": "0.247.1"
}
}
12 changes: 10 additions & 2 deletions _generated/SshV0_Node20/ssh2helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ export function runCommandOnRemoteMachine(
}).on('data', (data) => {
if (data) {
// "data" can be a buffer. Format it here so it outputs as a string
console.log(data.toString('utf8'));
if (tl.getPipelineFeature("redirectTaskOutputToProcessStdout")) {
process.stdout.write(data);
} else {
console.log(data.toString('utf8'));
}
if (!passwordSent) {
passwordSent = handlePasswordInput(data, stream, password, dataBuffer);
if (passwordSent) {
Expand All @@ -174,7 +178,11 @@ export function runCommandOnRemoteMachine(
}).on('data', (data) => {
if (data) {
// "data" can be a buffer. Format it here so it outputs as a string
console.log(data.toString('utf8'));
if (tl.getPipelineFeature("redirectTaskOutputToProcessStdout")) {
process.stdout.write(data);
} else {
console.log(data.toString('utf8'));
}
}
}).stderr.on('data', (data) => {
stdErrWritten = true;
Expand Down
6 changes: 3 additions & 3 deletions _generated/SshV0_Node20/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 245,
"Minor": 247,
"Patch": 1
},
"demands": [],
Expand Down Expand Up @@ -169,7 +169,7 @@
"ScriptArgsSanitized": "Detected characters in arguments that may not be executed correctly by the shell. Please escape special characters using backslash (\\). More information is available here: https://aka.ms/ado/75787"
},
"_buildConfigMapping": {
"Default": "0.245.0",
"Node20-225": "0.245.1"
"Default": "0.247.0",
"Node20-225": "0.247.1"
}
}
6 changes: 3 additions & 3 deletions _generated/SshV0_Node20/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 245,
"Minor": 247,
"Patch": 1
},
"demands": [],
Expand Down Expand Up @@ -169,7 +169,7 @@
"ScriptArgsSanitized": "ms-resource:loc.messages.ScriptArgsSanitized"
},
"_buildConfigMapping": {
"Default": "0.245.0",
"Node20-225": "0.245.1"
"Default": "0.247.0",
"Node20-225": "0.247.1"
}
}

0 comments on commit e606f44

Please sign in to comment.