azure-pipelines-tasks: Azure CLI Task: az account clear fails

Environment

  • Server - VSTS or TFS on-premises? VSTS

  • Agent - Hosted or Private: Linux Hosted Preview

Issue Description

Our build has started to consistently fail because of Azure CLI task. The task fails at the last step az account clear. This is a regression since it was working the week before. Version: 1.*

Error logs

2018-02-27T18:12:41.4138212Z ##[debug]Evaluating condition for step: 'Download dependencies'
2018-02-27T18:12:41.4166697Z ##[debug]Evaluating: succeeded()
2018-02-27T18:12:41.4188348Z ##[debug]Evaluating succeeded:
2018-02-27T18:12:41.4219635Z ##[debug]=> (Boolean) True
2018-02-27T18:12:41.4242159Z ##[debug]Expanded: True
2018-02-27T18:12:41.4263812Z ##[debug]Result: True
2018-02-27T18:12:41.4285833Z ##[section]Starting: Download dependencies
2018-02-27T18:12:41.4612898Z ==============================================================================
2018-02-27T18:12:41.4628162Z Task         : Azure CLI
2018-02-27T18:12:41.4642343Z Description  : Run a Shell or Batch script with Azure CLI commands against an azure subscription
2018-02-27T18:12:41.4656829Z Version      : 1.130.0
2018-02-27T18:12:41.4671633Z Author       : Microsoft Corporation
2018-02-27T18:12:41.4686463Z Help         : [More Information](http://go.microsoft.com/fwlink/?LinkID=827160)
2018-02-27T18:12:41.4701934Z ==============================================================================
2018-02-27T18:12:43.1606295Z ##[debug]agent.workFolder=/opt/vsts/work
2018-02-27T18:12:43.1633569Z ##[debug]loading inputs and endpoints
2018-02-27T18:12:43.1660490Z ##[debug]loading INPUT_CONNECTEDSERVICENAMEARM
2018-02-27T18:12:43.1689378Z ##[debug]loading INPUT_SCRIPTLOCATION
2018-02-27T18:12:43.1722079Z ##[debug]loading INPUT_SCRIPTPATH
2018-02-27T18:12:43.1745656Z ##[debug]loading INPUT_INLINESCRIPT
2018-02-27T18:12:43.1768377Z ##[debug]loading INPUT_CWD
2018-02-27T18:12:43.1791483Z ##[debug]loading INPUT_FAILONSTANDARDERROR
2018-02-27T18:12:43.1817864Z ##[debug]loading ENDPOINT_AUTH_af68dcbd-55f0-447c-9c67-8f8c1fc3b5b9
2018-02-27T18:12:43.1847121Z ##[debug]loading ENDPOINT_AUTH_SCHEME_af68dcbd-55f0-447c-9c67-8f8c1fc3b5b9
2018-02-27T18:12:43.1873242Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_af68dcbd-55f0-447c-9c67-8f8c1fc3b5b9_SERVICEPRINCIPALID
2018-02-27T18:12:43.1901373Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_af68dcbd-55f0-447c-9c67-8f8c1fc3b5b9_SERVICEPRINCIPALKEY
2018-02-27T18:12:43.1929312Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_af68dcbd-55f0-447c-9c67-8f8c1fc3b5b9_TENANTID
2018-02-27T18:12:43.1953936Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2018-02-27T18:12:43.1977635Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2018-02-27T18:12:43.2000850Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2018-02-27T18:12:43.2025522Z ##[debug]loaded 14
2018-02-27T18:12:43.2050235Z ##[debug]check path : /opt/vsts/work/_tasks/AzureCLI_46e4be58-730b-4389-8a2f-ea10b3e5e815/1.130.0/task.json
2018-02-27T18:12:43.2077832Z ##[debug]set resource file to: /opt/vsts/work/_tasks/AzureCLI_46e4be58-730b-4389-8a2f-ea10b3e5e815/1.130.0/task.json
2018-02-27T18:12:43.2106084Z ##[debug]system.culture=en-US
2018-02-27T18:12:43.2131985Z ##[debug]az=/usr/bin/az
2018-02-27T18:12:43.2157804Z ##[debug]check path : /bin/bash
2018-02-27T18:12:43.2183002Z ##[debug]bash=/bin/bash
2018-02-27T18:12:43.2206788Z ##[debug]scriptLocation=inlineScript
2018-02-27T18:12:43.2230636Z ##[debug]cwd=/opt/vsts/work/1/s
2018-02-27T18:12:43.2259870Z ##[debug]inlineScript=az storage file download --account-name builddep --share-name builddep --path $PACKAGENAME.zip
2018-02-27T18:12:43.2286304Z ##[debug]args=null
2018-02-27T18:12:43.2310856Z ##[debug]failOnStandardError=true
2018-02-27T18:12:43.2335870Z ##[debug]testing directory '/opt/vsts/work/1/s'
2018-02-27T18:12:43.2361339Z ##[debug]/bin/bash arg: /tmp/azureclitaskscript1519755163164.sh
2018-02-27T18:12:43.2389165Z ##[debug]connectedServiceNameARM=af68dcbd-55f0-447c-9c67-8f8c1fc3b5b9
2018-02-27T18:12:43.2417999Z ##[debug]af68dcbd-55f0-447c-9c67-8f8c1fc3b5b9 auth param serviceprincipalid = ********
2018-02-27T18:12:43.2454580Z ##[debug]af68dcbd-55f0-447c-9c67-8f8c1fc3b5b9 auth param serviceprincipalkey = ********
2018-02-27T18:12:43.2490884Z ##[debug]af68dcbd-55f0-447c-9c67-8f8c1fc3b5b9 auth param tenantid = ********
2018-02-27T18:12:43.2517883Z ##[debug]af68dcbd-55f0-447c-9c67-8f8c1fc3b5b9 data SubscriptionName = Internal
2018-02-27T18:12:43.2544612Z ##[debug]check path : /usr/bin/az
2018-02-27T18:12:43.2570793Z ##[debug]az=/usr/bin/az
2018-02-27T18:12:43.2597775Z ##[debug]/usr/bin/az arg: login --service-principal -u "********" -p ******** --tenant "********"
2018-02-27T18:12:43.2626792Z ##[debug]/usr/bin/az arg: login --service-principal -u "********" -p ******** --tenant "********"
2018-02-27T18:12:43.2651743Z ##[debug]exec tool: /usr/bin/az
2018-02-27T18:12:43.2678416Z ##[debug]exec tool: /usr/bin/az
2018-02-27T18:12:43.2700985Z ##[debug]Arguments:
2018-02-27T18:12:43.2723627Z ##[debug]Arguments:
2018-02-27T18:12:43.2746497Z ##[debug]   login
2018-02-27T18:12:43.2772399Z ##[debug]   login
2018-02-27T18:12:43.2796789Z ##[debug]   --service-principal
2018-02-27T18:12:43.2823308Z ##[debug]   --service-principal
2018-02-27T18:12:43.2849232Z ##[debug]   -u
2018-02-27T18:12:43.2875323Z ##[debug]   -u
2018-02-27T18:12:43.2905554Z ##[debug]   ********
2018-02-27T18:12:43.2929850Z ##[debug]   ********
2018-02-27T18:12:43.2954185Z ##[debug]   -p
2018-02-27T18:12:43.2983370Z ##[debug]   -p
2018-02-27T18:12:43.3012114Z ##[debug]   ********
2018-02-27T18:12:43.3034837Z ##[debug]   ********
2018-02-27T18:12:43.3059255Z ##[debug]   --tenant
2018-02-27T18:12:43.3099072Z ##[debug]   --tenant
2018-02-27T18:12:43.3126215Z ##[debug]   ********
2018-02-27T18:12:43.3150432Z ##[debug]   ********
2018-02-27T18:12:43.3168527Z [command]/usr/bin/az login --service-principal -u ******** -p ******** --tenant ********
2018-02-27T18:12:53.5716651Z [
2018-02-27T18:12:53.5732517Z   {
2018-02-27T18:12:53.5750306Z     "cloudName": "AzureCloud",
2018-02-27T18:12:53.5766010Z     "id": "cb4970ea-4a04-40b6-8177-ab021cc5690f",
2018-02-27T18:12:53.5783002Z     "isDefault": true,
2018-02-27T18:12:53.5797086Z     "name": "Internal",
2018-02-27T18:12:53.5811485Z     "state": "Enabled",
2018-02-27T18:12:53.5828096Z     "tenantId": "********",
2018-02-27T18:12:53.5842070Z     "user": {
2018-02-27T18:12:53.5858139Z       "name": "********",
2018-02-27T18:12:53.5872510Z       "type": "servicePrincipal"
2018-02-27T18:12:53.5886925Z     }
2018-02-27T18:12:53.5905142Z   }
2018-02-27T18:12:53.5923833Z ]
2018-02-27T18:12:53.5947835Z ##[debug]check path : /usr/bin/az
2018-02-27T18:12:53.5970563Z ##[debug]az=/usr/bin/az
2018-02-27T18:12:53.5994896Z ##[debug]/usr/bin/az arg: account set --subscription "Internal"
2018-02-27T18:12:53.6022393Z ##[debug]/usr/bin/az arg: account set --subscription "Internal"
2018-02-27T18:12:53.6049645Z ##[debug]exec tool: /usr/bin/az
2018-02-27T18:12:53.6073969Z ##[debug]exec tool: /usr/bin/az
2018-02-27T18:12:53.6097721Z ##[debug]Arguments:
2018-02-27T18:12:53.6124056Z ##[debug]Arguments:
2018-02-27T18:12:53.6149083Z ##[debug]   account
2018-02-27T18:12:53.6174451Z ##[debug]   account
2018-02-27T18:12:53.6198100Z ##[debug]   set
2018-02-27T18:12:53.6222929Z ##[debug]   set
2018-02-27T18:12:53.6247350Z ##[debug]   --subscription
2018-02-27T18:12:53.6273927Z ##[debug]   --subscription
2018-02-27T18:12:53.6297976Z ##[debug]   Internal
2018-02-27T18:12:53.6321123Z ##[debug]   Internal
2018-02-27T18:12:53.6337307Z [command]/usr/bin/az account set --subscription Internal
2018-02-27T18:12:54.4233510Z ##[debug]exec tool: /bin/bash
2018-02-27T18:12:54.4256887Z ##[debug]Arguments:
2018-02-27T18:12:54.4280577Z ##[debug]   /tmp/azureclitaskscript1519755163164.sh
2018-02-27T18:12:54.4295293Z [command]/bin/bash /tmp/azureclitaskscript1519755163164.sh
2018-02-27T18:12:57.0221249Z 
2018-02-27T18:12:57.0239002Z Alive[################################################################]  100.0000%
2018-02-27T18:12:57.0408120Z Finished[#############################################################]  100.0000%
2018-02-27T18:12:57.0424724Z {
2018-02-27T18:12:57.0439688Z   "content": null,
2018-02-27T18:12:57.0456418Z   "metadata": {},
2018-02-27T18:12:57.0474047Z   "name": "package.zip",
2018-02-27T18:12:57.0490449Z   "properties": {
2018-02-27T18:12:57.0504589Z     "contentLength": 16365416,
2018-02-27T18:12:57.0520631Z     "contentRange": "bytes 0-16365415/16365416",
2018-02-27T18:12:57.0536590Z     "contentSettings": {
2018-02-27T18:12:57.0555404Z       "cacheControl": null,
2018-02-27T18:12:57.0570165Z       "contentDisposition": null,
2018-02-27T18:12:57.0665590Z       "contentEncoding": null,
2018-02-27T18:12:57.0681069Z       "contentLanguage": null,
2018-02-27T18:12:57.0695566Z       "contentType": null
2018-02-27T18:12:57.0710892Z     },
2018-02-27T18:12:57.0725280Z     "copy": {
2018-02-27T18:12:57.0820964Z       "completionTime": null,
2018-02-27T18:12:57.0837878Z       "id": null,
2018-02-27T18:12:57.0863189Z       "progress": null,
2018-02-27T18:12:57.0881693Z       "source": null,
2018-02-27T18:12:57.0896123Z       "status": null,
2018-02-27T18:12:57.0995367Z       "statusDescription": null
2018-02-27T18:12:57.1010192Z     },
2018-02-27T18:12:57.1024783Z     "etag": "\"0x8D57A3B4DE2C899\"",
2018-02-27T18:12:57.1041753Z     "lastModified": "2018-02-22T21:29:07+00:00",
2018-02-27T18:12:57.1058825Z     "serverEncrypted": true
2018-02-27T18:12:57.1196221Z   }
2018-02-27T18:12:57.1210300Z }
2018-02-27T18:12:57.4209475Z ##[debug]rc:0
2018-02-27T18:12:57.4232988Z ##[debug]success:false
2018-02-27T18:12:57.4263585Z ##[debug]check path : /usr/bin/az
2018-02-27T18:12:57.4287110Z ##[debug]az=/usr/bin/az
2018-02-27T18:12:57.4310513Z ##[debug]/usr/bin/az arg:  account clear
2018-02-27T18:12:57.4333098Z ##[debug]/usr/bin/az arg:  account clear
2018-02-27T18:12:57.4356669Z ##[debug]exec tool: /usr/bin/az
2018-02-27T18:12:57.4384192Z ##[debug]exec tool: /usr/bin/az
2018-02-27T18:12:57.4407116Z ##[debug]Arguments:
2018-02-27T18:12:57.4430635Z ##[debug]Arguments:
2018-02-27T18:12:57.4456033Z ##[debug]   account
2018-02-27T18:12:57.4484368Z ##[debug]   account
2018-02-27T18:12:57.4518856Z ##[debug]   clear
2018-02-27T18:12:57.4543182Z ##[debug]   clear
2018-02-27T18:12:57.4558415Z [command]/usr/bin/az account clear
2018-02-27T18:12:58.3529617Z ##[debug]task result: Failed
2018-02-27T18:12:58.3626548Z ##[error]Script failed with error: Error: /bin/bash failed with return code: 0
2018-02-27T18:12:58.3667232Z ##[debug]Processed: ##vso[task.issue type=error;]Script failed with error: Error: /bin/bash failed with return code: 0
2018-02-27T18:12:58.3727328Z ##[debug]Processed: ##vso[task.complete result=Failed;]Script failed with error: Error: /bin/bash failed with return code: 0
2018-02-27T18:12:58.4516730Z ##[section]Finishing: Download dependencies

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 27 (12 by maintainers)

Most upvoted comments

@hiyadav thanks for your answer the az cli is the latest version available (2.0.55) as I have mentioned before, the weird thing is when the tfs agent is in the interactive mode (./run.sh) it goes through fine. but when I put the agent in the serviced mode it gives me the error that I have mentioned. And also “FailOnStandardError = false” is not an option for me since I want to fail the build process when an actual error is happening. If I change the variable to “true” it never fails and I cannot use it. Is there any other workaround available?

This workaround doesn’t work:

  1. It’s not our script that is writing to stderr. It’s the task writing to stderr when it is calling az account clear
  2. FailOnStandardError is false on our task

This is still an active issue and it is not fixed yet. The solution suggested by @hiyadav cannot be applied in all circumstances because it will falsely cover all the actual errors as well which is not the right way of recovering from this.

@farchide If the script is throwing an error (writing something to stderr) which is leading for the task to fail when FailOnStandardError=true. To avoid the failure, you might need to redirect the standard error stream to standard output for executing that command in the script. this way you will be able to see the error inside the output of the script and any other error will not get masked.

If this doesn’t help, can you share the release/build logs with system.debug=true