Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
322 stars 54 forks source link

Unable to deploy static web app using Azure DevOps and self hosted Windows agent #509

Open tomaustin700 opened 3 years ago

tomaustin700 commented 3 years ago

Describe the bug

Attempting to deploy a static web app using Azure DevOps pipelines and a self hosted Windows agents results in the AzureStaticWebApp task failing with no error message.

To Reproduce Steps to reproduce the behavior:

  1. Create a new Azure DevOps yaml pipeline to deploy a static web app
  2. Set the pipeline to use a self-hosted Windows agent (this can probably be duplicated using a hosted Windows agent as well)
  3. Pipeline will fail but no error message is shown

Only way to figure out what's going on is to set system.debug to true on the pipeline and read the logs.

Expected behavior Task should either work on Windows agents or just give a meaningful error message

Screenshots image

miwebst commented 3 years ago

Hey @tomaustin700 , this is a known issue. Currently the Static Web Apps deployment task must be run on Linux machines.

tomaustin700 commented 3 years ago

Hi @miwebst, is that actually documented anywhere? I've not seen any mention of it in any of the documentation. Ideally the task should output something describing the issue also as currently there is no output whatsoever.

miwebst commented 3 years ago

Hey @tomaustin700 , you are 100% right. I've updated our docs: https://docs.microsoft.com/en-us/azure/static-web-apps/publish-devops to say:

"The Static Web App Pipeline Task currently only works on Linux machines. When running the pipeline mentioned below, please ensure it is running on a Linux VM."

I agree the ideal behavior would be for the output to say why its not running, we can take a look at updating our task to do this.

tomaustin700 commented 3 years ago

Thanks @miwebst, is the task on github anywhere? If so I'm happy to take a look and submit a PR for the output change.

miwebst commented 3 years ago

Yes you can find the DevOps task code here: https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/AzureStaticWebAppV0/index.ts

Likely the fix is to detect the OS in index.ts (before we launch the container) and output if not Linux.

tomaustin700 commented 3 years ago

Hi @miwebst, I've raised the following PR if you wouldn't mind taking a look. Thanks https://github.com/microsoft/azure-pipelines-tasks/pull/15104

anthonychu commented 3 years ago

Thanks for the PR. Agree that it’s good to add the message.

However, I don’t think the OS really determines whether or not the build container will run. The task currently requires the agent to be able to execute a bash script, and that the Docker client is installed and using a Docker host that is capable of running Linux-x64 containers. A better long term fix might be to remove the bash dependency and run a Docker command (docker info?) to confirm it can run Linux containers.

tomaustin700 commented 3 years ago

@anthonychu Thanks for the feedback, that does sound like a better solution however I don't think I have the skills to implement that. I've had a quick look at some of the other tasks and from what I can see no others use docker to run the task so I'm not really sure where to start. If you could give me some pointers I'll happily give this a try though! Thanks

anthonychu commented 3 years ago

Yep no worries. Just adding a note for revisiting at a later time. Your PR looks good.