microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.51k stars 2.62k forks source link

Azure Pipelines Azure CLI task - no colors when doing Bicep deployment #15473

Open chudytom opened 3 years ago

chudytom commented 3 years ago

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name: AzureCLI@2

Environment

Issue Description

I tried to deployed infrastructure using Azure Bicep. I did it using Azure CLI and specifically AzureCLI@2 task. It works, however when I use --what-if functionality the changes I see on the screen have no colors, which make the output much harder to read. When I run the same commands from my local CLI all the colors are visible.

Command used - az deployment group create -f infrastructure/bicep/<project-name>.bicep --subscription=<project-name> -g <project-name> --parameters env=dev --mode=complete --name=<project-name>_20211103_1243 --what-if

Current behavior: image

Expected behavior (from my local machine) image

Task logs

Will provide it later if really needed

Troubleshooting

Checkout how to troubleshoot failures and collect debug logs: https://docs.microsoft.com/en-us/vsts/build-release/actions/troubleshooting

Done

Error logs

No errors even after enabling system diagnostics

brettpostin commented 2 years ago

This isn't specific to bicep templates either. I have a release stage to do a what-if analysis for approval on a compiled bicep template (so json).

The colour coding would be really helpful.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

chudytom commented 2 years ago

@bishal-pdMSFT is there maybe any action planned on this issue?

bishal-pdMSFT commented 2 years ago

@naga-bandi can you please ask someone to look at thia

NAGA-BANDI commented 2 years ago

Ack'ed @@.**@.>.

@Renukadevi Vairavelu (MINDTREE @.***>: Please look into this.

Thanks, Naga Bandi | +91 99 89 233 944

From: Bishal Prasad @.> Sent: Sunday, August 7, 2022 5:54 PM To: microsoft/azure-pipelines-tasks @.> Cc: Naga Varaprasad Bandi (MINDTREE LIMITED) @.>; Mention @.> Subject: Re: [microsoft/azure-pipelines-tasks] Azure Pipelines Azure CLI task - no colors when doing Bicep deployment (Issue #15473)

@NAGA-BANDIhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FNAGA-BANDI&data=05%7C01%7CV-NABAND%40MICROSOFT.COM%7C5a704b602b0d4633acfa08da786fc632%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637954718800079206%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=dG3DSwpQbCGO8yGvwCMxlsIV%2B21wsyp5B89xA3Jmvx0%3D&reserved=0 can you please ask someone to look at thia

- Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fazure-pipelines-tasks%2Fissues%2F15473%23issuecomment-1207396724&data=05%7C01%7CV-NABAND%40MICROSOFT.COM%7C5a704b602b0d4633acfa08da786fc632%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637954718800079206%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=a%2F7IvjvfZo5P7CEokzJnF0g%2BagdstO0rpD43li89jos%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAP4VJIC2XLCAENFRBFXHRALVX6THZANCNFSM5HI3BAFQ&data=05%7C01%7CV-NABAND%40MICROSOFT.COM%7C5a704b602b0d4633acfa08da786fc632%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637954718800079206%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=PesQODXi3l6Z7nnURezUUAC2e9qeekQ5k7Ob4%2FsrzEU%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.**@.>>

NAGA-BANDI commented 2 years ago

Sure Naga, will check on this

Regards, Renukadevi V

From: Naga Varaprasad Bandi (MINDTREE LIMITED) @.> Sent: Sunday, August 7, 2022 11:40 PM To: microsoft/azure-pipelines-tasks @.>; microsoft/azure-pipelines-tasks @.>; @.; Renukadevi Vairavelu (MINDTREE LIMITED) @.> Cc: Mention @.> Subject: RE: [microsoft/azure-pipelines-tasks] Azure Pipelines Azure CLI task - no colors when doing Bicep deployment (Issue #15473)

Ack'ed @@.**@.>.

@Renukadevi Vairavelu (MINDTREE @.***>: Please look into this.

Thanks, Naga Bandi | +91 99 89 233 944

From: Bishal Prasad @.**@.>> Sent: Sunday, August 7, 2022 5:54 PM To: microsoft/azure-pipelines-tasks @.**@.>> Cc: Naga Varaprasad Bandi (MINDTREE LIMITED) @.**@.>>; Mention @.**@.>> Subject: Re: [microsoft/azure-pipelines-tasks] Azure Pipelines Azure CLI task - no colors when doing Bicep deployment (Issue #15473)

@NAGA-BANDIhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FNAGA-BANDI&data=05%7C01%7Cv-rvairavelu%40microsoft.com%7C4ac981fa564946f4199408da789fff99%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637954925900131467%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=aoBuS5HoKiQXl25iX5DhPau6D35312meXfl3%2FKKV6W0%3D&reserved=0 can you please ask someone to look at thia

- Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fazure-pipelines-tasks%2Fissues%2F15473%23issuecomment-1207396724&data=05%7C01%7Cv-rvairavelu%40microsoft.com%7C4ac981fa564946f4199408da789fff99%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637954925900131467%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=JL%2FVP9woES3FZ4xxI63My8sA9sZ0JHmOkC1M2u1%2BWOs%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAP4VJIC2XLCAENFRBFXHRALVX6THZANCNFSM5HI3BAFQ&data=05%7C01%7Cv-rvairavelu%40microsoft.com%7C4ac981fa564946f4199408da789fff99%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637954925900131467%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=HdE9J%2FcxTkFwzPVoc7flWsTtqUoS88rUcAeDcd8XnYs%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.**@.>>

v-nagarajku commented 2 years ago

Hi @chudytom

1.As per our understanding we believe from AzureCLI@2 task script type was selected as PowerShellCore which is responsible for the color coding. Is the agent machine(self-hosted) having PowerShell core installed explicitly or is it a MS Hosted agent?

2.Please share the complete logs for further investigation. Both successful logs and failure logs from the task.

htuomola commented 2 years ago

@v-nagarajku Colors are also not showing on hosted ubuntu-latest agent either, with task AzureCLI@2

- task: AzureCLI@2
  inputs:
    azureSubscription: <connection name>
    scriptType: bash
    scriptLocation: inlineScript
    inlineScript: |
      az --version
      az deployment sub create --what-if --location <....params>

image

also running on hosted windows-latest agent with scriptType: pscore makes no difference.

vs. in windows local terminal (ps core) image

ekersale commented 1 year ago

@v-nagarajku Any update here ?

NAGA-BANDI commented 1 year ago

@@.***>.

Thanks, Naga Bandi | +91 99 89 233 944 @.***

From: Elliot Kersalé @.> Sent: Wednesday, February 1, 2023 3:21 AM To: microsoft/azure-pipelines-tasks @.> Cc: Naga Varaprasad Bandi (MINDTREE LIMITED) @.>; Mention @.> Subject: Re: [microsoft/azure-pipelines-tasks] Azure Pipelines Azure CLI task - no colors when doing Bicep deployment (Issue #15473)

Any update here ?

- Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fazure-pipelines-tasks%2Fissues%2F15473%23issuecomment-1411116610&data=05%7C01%7CV-NABAND%40MICROSOFT.COM%7Ced1d4309259c41d20a4e08db03d54d2d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638107986916871881%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=wy5bqlOvnykKvcrutQ%2FkP2u10meCTz3OXnihDEuK59A%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAP4VJIH2HUKIAZUAHYOWIG3WVGCN3ANCNFSM5HI3BAFQ&data=05%7C01%7CV-NABAND%40MICROSOFT.COM%7Ced1d4309259c41d20a4e08db03d54d2d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638107986917028108%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=EWk%2FODkoUWOiIo9f4bG5Ix%2BSkcy3u6C6eTIQmm0xLSw%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.**@.>>

rvairavelu commented 1 year ago

@ekersale. This feature is not implemented. At present, we could not prioritize it, due to other critical issues in our queue. cc @vijayma @NAGA-BANDI @v-nagarajku

Kravca commented 1 year ago

Anybody got some workaround for this?

roofiq commented 1 year ago

Up, it would be really handy

Rod-Sychev commented 1 year ago

Come on MSFT, this is basics!

miniGweek commented 1 year ago

MSFT Team, this is important! While running the What-if step of bicep templates in our pipeline we need to see a colored output to make sense of what's getting modified, deleted or added! This is basics! Please prioritize this!!

arwinters commented 1 year ago

Yes MSFT we are waiting on it.

TiTi commented 9 months ago

Any update on this topic ?

Azure declarative IaC language which is recommended is Bicep (see green box here: https://learn.microsoft.com/en-us/azure/templates/) Unfortunately no color in Azure DevOps :-/ This is a real turn down for team work with centralized pipeline!

Can we please have a little bit of color for bicep in Azure DevOps ?

Note: color is working with terraform....

anthony-c-martin commented 9 months ago

I did some digging on this, and chatted to @JamieMagee who gave me some great pointers.

Current theory:

We do not believe this was a deliberate decision - just an accidental result of the indirection.

An interesting test would be to try and set the env variable FORCE_COLOR to 1 to override Node's built-in color detection: https://nodejs.org/api/tty.html#writestreamgetcolordepthenv.

TiTi commented 9 months ago

Thanks for digging this @anthony-c-martin . Just tried it without success :/

anthony-c-martin commented 9 months ago

Seems related to https://github.com/microsoft/azure-pipelines-agent/issues/1569. AzureCLI uses 8bit color codes, which are unsupported by ADO.

slavizh commented 9 months ago

There is some not pretty workaround for PowerShell https://paul-mackinnon.medium.com/azure-devops-ansi-colour-coding-df8ef7406422 It is not pretty as not everything is 100% as would appear in regular PowerShell console. Overall the right way would be ADO to support 8bit color codes instead of Bicep team or we implement workarounds.

TiTi commented 9 months ago

Whatever I try, I can't output the escape sequence (ex: `e[34m) even when trying to save **az cli** output in a file. (az deployment group what-if ...`) Thus the powershell workaround doesn't even work for az cli. (i couldn't use New-Az[Subscription]Deployment because it didn't handle .bicepparam until recently ; and I just tried but got other issues preventing me to use it, it's a mess!)

It would be nice to have an option like PY_COLORS or ANSIBLE_FORCE_COLOR
"This option forces color mode even when running without a TTY"

vuylstekeb commented 8 months ago

+1 would be really useful to have

Saulopv commented 2 weeks ago

+1 basic feature really..