Skip to content

Commit f38ab47

Browse files
Users/shigupt/porting helm std err to164 (#12341)
* Support failOnStdErr on Helm Task (#12211) * add failOnStdErr to helm * Updating task version * Updating task version Co-authored-by: balteravishay <[email protected]>
1 parent 696966e commit f38ab47

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

Tasks/HelmDeployV0/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
"loc.input.help.privatekey": "Specify Tiller Key or Helm client key",
7070
"loc.input.label.tillernamespace": "Tiller namespace",
7171
"loc.input.help.tillernamespace": "Specify K8 namespace of tiller.",
72+
"loc.input.label.failOnStderr": "Fail on Standard Error",
73+
"loc.input.help.failOnStderr": "If this is true, this task will fail if any errors are written to the error pipeline, or if any data is written to the Standard Error stream. Otherwise the task will rely on the exit code to determine failure.",
7274
"loc.messages.CantDownloadAccessProfile": "Cannot download access profile/kube config file for the cluster %s. Reason %s.",
7375
"loc.messages.KubeConfigFilePath": "Kubeconfig file path: %s",
7476
"loc.messages.KubernetesClusterInfo": "Kubernetes cluster Id : %s, kubernetes server version %s, kuberenettes provision state %s",

Tasks/HelmDeployV0/src/helm.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ async function run() {
7373
command: command,
7474
jobId: tl.getVariable('SYSTEM_JOBID')
7575
};
76+
var failOnStderr = tl.getBoolInput("failOnStderr");
7677

7778
console.log("##vso[telemetry.publish area=%s;feature=%s]%s",
7879
"TaskEndpointId",
@@ -88,7 +89,7 @@ async function run() {
8889
kubectlCli.unsetKubeConfigEnvVariable();
8990
break;
9091
default:
91-
runHelm(helmCli, command, kubectlCli);
92+
runHelm(helmCli, command, kubectlCli, failOnStderr);
9293
}
9394
} catch (err) {
9495
// not throw error so that we can logout from helm and kubernetes
@@ -103,7 +104,7 @@ async function run() {
103104
}
104105
}
105106

106-
function runHelm(helmCli: helmcli, command: string, kubectlCli: kubernetescli) {
107+
function runHelm(helmCli: helmcli, command: string, kubectlCli: kubernetescli, failOnStderr: boolean) {
107108
var helmCommandMap = {
108109
"init": "./helmcommands/helminit",
109110
"install": "./helmcommands/helminstall",
@@ -124,7 +125,7 @@ function runHelm(helmCli: helmcli, command: string, kubectlCli: kubernetescli) {
124125
commandImplementation.addArguments(helmCli);
125126

126127
const execResult = helmCli.execHelmCommand();
127-
if (execResult.code != tl.TaskResult.Succeeded || !!execResult.error || !!execResult.stderr) {
128+
if (execResult.code != tl.TaskResult.Succeeded || !!execResult.error || (failOnStderr && !!execResult.stderr)) {
128129
tl.debug('execResult: ' + JSON.stringify(execResult));
129130
tl.setResult(tl.TaskResult.Failed, execResult.stderr);
130131
}

Tasks/HelmDeployV0/task.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"version": {
1515
"Major": 0,
1616
"Minor": 164,
17-
"Patch": 2
17+
"Patch": 3
1818
},
1919
"demands": [],
2020
"groups": [{
@@ -383,6 +383,14 @@
383383
"helpMarkDown": "Specify K8 namespace of tiller.",
384384
"type": "string",
385385
"groupName": "advanced"
386+
},
387+
{
388+
"name": "failOnStderr",
389+
"type": "boolean",
390+
"label": "Fail on Standard Error",
391+
"defaultValue": "true",
392+
"helpMarkDown": "If this is true, this task will fail if any errors are written to the error pipeline, or if any data is written to the Standard Error stream. Otherwise the task will rely on the exit code to determine failure.",
393+
"groupName": "advanced"
386394
}
387395
],
388396
"dataSourceBindings": [{
@@ -438,4 +446,4 @@
438446
"KubernetesServiceConnectionNotFound": "Kubernetes service connection details not found.",
439447
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
440448
}
441-
}
449+
}

Tasks/HelmDeployV0/task.loc.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"version": {
1515
"Major": 0,
1616
"Minor": 164,
17-
"Patch": 2
17+
"Patch": 3
1818
},
1919
"demands": [],
2020
"groups": [{
@@ -383,6 +383,14 @@
383383
"helpMarkDown": "ms-resource:loc.input.help.tillernamespace",
384384
"type": "string",
385385
"groupName": "advanced"
386+
},
387+
{
388+
"name": "failOnStderr",
389+
"type": "boolean",
390+
"label": "ms-resource:loc.input.label.failOnStderr",
391+
"defaultValue": "true",
392+
"helpMarkDown": "ms-resource:loc.input.help.failOnStderr",
393+
"groupName": "advanced"
386394
}
387395
],
388396
"dataSourceBindings": [{

0 commit comments

Comments
 (0)