From f38ab4754ce46127072806eecf1ca11525c66e47 Mon Sep 17 00:00:00 2001 From: shigupt202 <57620559+shigupt202@users.noreply.github.com> Date: Wed, 12 Feb 2020 10:55:46 +0530 Subject: [PATCH] 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 --- .../resources.resjson/en-US/resources.resjson | 2 ++ Tasks/HelmDeployV0/src/helm.ts | 7 ++++--- Tasks/HelmDeployV0/task.json | 12 ++++++++++-- Tasks/HelmDeployV0/task.loc.json | 10 +++++++++- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Tasks/HelmDeployV0/Strings/resources.resjson/en-US/resources.resjson b/Tasks/HelmDeployV0/Strings/resources.resjson/en-US/resources.resjson index f91b9c83fda0..647a0b20a5c6 100644 --- a/Tasks/HelmDeployV0/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/HelmDeployV0/Strings/resources.resjson/en-US/resources.resjson @@ -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", diff --git a/Tasks/HelmDeployV0/src/helm.ts b/Tasks/HelmDeployV0/src/helm.ts index e7f0c5f1be10..3088a0b2ceaa 100644 --- a/Tasks/HelmDeployV0/src/helm.ts +++ b/Tasks/HelmDeployV0/src/helm.ts @@ -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", @@ -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 @@ -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", @@ -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); } diff --git a/Tasks/HelmDeployV0/task.json b/Tasks/HelmDeployV0/task.json index 7482d7b611d5..da0710f3e476 100644 --- a/Tasks/HelmDeployV0/task.json +++ b/Tasks/HelmDeployV0/task.json @@ -14,7 +14,7 @@ "version": { "Major": 0, "Minor": 164, - "Patch": 2 + "Patch": 3 }, "demands": [], "groups": [{ @@ -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": [{ @@ -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." } -} \ No newline at end of file +} diff --git a/Tasks/HelmDeployV0/task.loc.json b/Tasks/HelmDeployV0/task.loc.json index cf5fd113f3ee..86be02c92a85 100644 --- a/Tasks/HelmDeployV0/task.loc.json +++ b/Tasks/HelmDeployV0/task.loc.json @@ -14,7 +14,7 @@ "version": { "Major": 0, "Minor": 164, - "Patch": 2 + "Patch": 3 }, "demands": [], "groups": [{ @@ -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": [{