Troubleshoot Azure Devops Agents
Recently I have been automating all the things and recently had a nuxt project that would successfully build, but no artifacts! So this article is more of an outline of the things I tried to narrow the issue down.
1. Turn on diagnostics
This adds a large variety of information to the output, but can help with checking environment variables, expose tasks output and current directory among others. Before this was only enable-able through environment variables but now clicking ‘Run pipeline’ and selecting enable system diagnostics
.
2. Add debug bash scripts to ‘feel out’ the issue
This is extremely wasteful, but can sometimes be useful.
3. Locally debug the agent via Docker!
Dockeried build agents are were a game-changer (they have been discontinued and everything has been moved to azure-pipelines-agent). I knew which command (yarn build
) was failing, so being able to start an exact environment as what is running on Azure Devops made the troubleshooting trivial.
looking at the dockerhub repository it seemed pretty straight forward to get an bash shell running with the command below:
docker run -e VSTS_ACCOUNT=TotallyFakeName \
-e VSTS_TOKEN=TotallyInvalidToken \
-v /var/run/docker.sock:/var/run/docker.sock \
--mount type=bind,source="$(pwd)",target=/app \
-it mcr.microsoft.com/azure-pipelines/vsts-agent:ubuntu-16.04-docker-17.12.0-ce sh
The important parts are adding your mount to the current directory (--mount type=bind,source="$(pwd)",target=/app
) to make debugging easier and adding bash(sh
). Also the VSTS_TOKEN
and VSTS_ACCOUNT
are intentionally invalid because there is no need to have official build running on a dev pc.
The new agents seem great, and even have a half-baked localRun
feature that is supposed to let you verify your build will work before failing the build serveral times greatly increasing the development cycle. Some more information is here and hopefully it gets fully supported in the future as I can only run it connected to a Azure Devops instance
The issue?
One of the files was name MyPascalCAseComponent.vue
, but the import in a parent component was MyPascalCaseComponent.vue
. As Ubuntu treats these as seperate files, it threw an error that was swallowed by either node or yarn.