In the previous chapter, we talked about how to handle bad situations (errors and exceptions) but specifically the bad situations that you were expecting. There’s another type of bad situation that can happen as your scripts become more and more complex. These situations, that we’ve alluded to already, are called bugs. These are the side effects of a long night scripting, or lack of coffee in the morning. In other words, they’re the side effects of us being human. We all make mistakes, and this chapter will be focused on some techniques on how to find and squash the bugs in your scripts.
NOTE
Without diving too deep into Azure Pipelines concepts, the script in listing 25.1 will get details about published artifacts we care about and download them to the Temp drive. If you’ve never heard the term artifact before, it’s basically a file that has been published somewhere other tools can download it. Additionally, you’ll notice some environment variables in the script (prefixed with $env:). This is because the script was written to be run inside of Azure Pipelines where these artifacts exist.