• Automation,  Azure,  Powershell

    Publish module to Powershell Gallery from Azure Pipelines

    Now that I have my module on Github and built the module on Azure Pipelines, I want to publish it to the Powershell Gallery. The first step it of course to create a free account; once you have the account you can head to your profile, click on API Keys and then Create: The Create dialog allows to choose the key name, the expiration and very important, the scope (what permission the key will have on the Gallery) and which packages the key is allowed to control through Global Pattern. In my case I want the key to expire every year, I want the key to grant permission to publish new packages and update existing ones and I want this key to be used only for LSE modules: notice I used LSE* as Global Pattern, this way this same key will allow me to publish and manage new packages as long as their name begins with LSE. Azure Pipelines allows to securely store secrets (passwords and keys) as variables, if you want to do so you can use the Variables tab in your Pipeline then click the padlock icon: Anyway I prefer to store the key in Azure KeyVault since…

  • Azure,  Powershell

    Run Pester tests on Azure Pipelines

    Now that I have some simple functions and some tests in my master branch on Github, I want to make sure the tests are executed (and pass!) every time I merge some new code. At this point I do not care too much about my dev branch because I know I’ll commit often and things will not always be stable, but I’ll make sure all my test will pass before I merge from dev to master (and later I way want to publish from master to the Powershell Gallery, but only if all tests pass of course!). The first thing I need is an account on Azure DevOps (you can start with a free account) and when ready, head to Pipelines then Builds: Since my code is in Github, that’s what I’ll choose: The first time we setup this integration, Azure Pipelines must be authorized to access Github: Since I don’t have a yaml file already, I’ll select Starter pipeline At this point in my tests things got a bit murky. The Azure Devops Marketplace has (as of this post) two free extensions to run Pester tasks so I decided to try them. I installed both extensions and added them…