Skip to content

Commit

Permalink
Users/shigupt/porting helm std err to164 (#12341)
Browse files Browse the repository at this point in the history
* Support failOnStdErr on Helm Task (#12211)

* add failOnStdErr to helm

* Updating task version

* Updating task version

Co-authored-by: balteravishay <[email protected]>
  • Loading branch information
shigupt202 and balteravishay authored Feb 12, 2020
1 parent 696966e commit f38ab47
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
"loc.input.help.privatekey": "Specify Tiller Key or Helm client key",
"loc.input.label.tillernamespace": "Tiller namespace",
"loc.input.help.tillernamespace": "Specify K8 namespace of tiller.",
"loc.input.label.failOnStderr": "Fail on Standard Error",
"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.",
"loc.messages.CantDownloadAccessProfile": "Cannot download access profile/kube config file for the cluster %s. Reason %s.",
"loc.messages.KubeConfigFilePath": "Kubeconfig file path: %s",
"loc.messages.KubernetesClusterInfo": "Kubernetes cluster Id : %s, kubernetes server version %s, kuberenettes provision state %s",
Expand Down
7 changes: 4 additions & 3 deletions Tasks/HelmDeployV0/src/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ async function run() {
command: command,
jobId: tl.getVariable('SYSTEM_JOBID')
};
var failOnStderr = tl.getBoolInput("failOnStderr");

console.log("##vso[telemetry.publish area=%s;feature=%s]%s",
"TaskEndpointId",
Expand All @@ -88,7 +89,7 @@ async function run() {
kubectlCli.unsetKubeConfigEnvVariable();
break;
default:
runHelm(helmCli, command, kubectlCli);
runHelm(helmCli, command, kubectlCli, failOnStderr);
}
} catch (err) {
// not throw error so that we can logout from helm and kubernetes
Expand All @@ -103,7 +104,7 @@ async function run() {
}
}

function runHelm(helmCli: helmcli, command: string, kubectlCli: kubernetescli) {
function runHelm(helmCli: helmcli, command: string, kubectlCli: kubernetescli, failOnStderr: boolean) {
var helmCommandMap = {
"init": "./helmcommands/helminit",
"install": "./helmcommands/helminstall",
Expand All @@ -124,7 +125,7 @@ function runHelm(helmCli: helmcli, command: string, kubectlCli: kubernetescli) {
commandImplementation.addArguments(helmCli);

const execResult = helmCli.execHelmCommand();
if (execResult.code != tl.TaskResult.Succeeded || !!execResult.error || !!execResult.stderr) {
if (execResult.code != tl.TaskResult.Succeeded || !!execResult.error || (failOnStderr && !!execResult.stderr)) {
tl.debug('execResult: ' + JSON.stringify(execResult));
tl.setResult(tl.TaskResult.Failed, execResult.stderr);
}
Expand Down
12 changes: 10 additions & 2 deletions Tasks/HelmDeployV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 164,
"Patch": 2
"Patch": 3
},
"demands": [],
"groups": [{
Expand Down Expand Up @@ -383,6 +383,14 @@
"helpMarkDown": "Specify K8 namespace of tiller.",
"type": "string",
"groupName": "advanced"
},
{
"name": "failOnStderr",
"type": "boolean",
"label": "Fail on Standard Error",
"defaultValue": "true",
"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.",
"groupName": "advanced"
}
],
"dataSourceBindings": [{
Expand Down Expand Up @@ -438,4 +446,4 @@
"KubernetesServiceConnectionNotFound": "Kubernetes service connection details not found.",
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
}
}
}
10 changes: 9 additions & 1 deletion Tasks/HelmDeployV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 164,
"Patch": 2
"Patch": 3
},
"demands": [],
"groups": [{
Expand Down Expand Up @@ -383,6 +383,14 @@
"helpMarkDown": "ms-resource:loc.input.help.tillernamespace",
"type": "string",
"groupName": "advanced"
},
{
"name": "failOnStderr",
"type": "boolean",
"label": "ms-resource:loc.input.label.failOnStderr",
"defaultValue": "true",
"helpMarkDown": "ms-resource:loc.input.help.failOnStderr",
"groupName": "advanced"
}
],
"dataSourceBindings": [{
Expand Down

0 comments on commit f38ab47

Please sign in to comment.