Using GIT for Powershell Development


I’ve been tasked with setting up a small team who will create wonderful pieces of Powershell automation, so I have been looking at version control, our choice is to go with GIT.

I’ve been playing about with it and I do want to keep it simple, we’ll have a test environment where we can develop the scripts and also run the scripts within that environment, then the same scripts will be promoted to our production environment.

So I was thinking of something along the lines of one repository, with a development branch and a test branch.

We would create the scripts in development, then merge into the test branch where they may be pushed via Jenkins or some other method. Once we are happy then merged into the master branch for production?

I’m basically looking for any good advice on the subject, anyone who has set up this type of environment before?



For my PowerShell modules, I try to follow this sort of pattern:

  1. Branches:
    • master - tested and working code. Tags are used to define specific commits as different versions.
    • <everything else>: various feature branches
  2. Process:
    • Develop everything on a feature branch, separately, as much as possible. If a feature has dependencies on several other features, sometimes there are secondary feature branches that get merged into primary feature branches.
    • Everything on a feature branch must be PRed into master, during which I verify all tests are running correctly, review changes and ensure any new tests needed have been added and are working as expected. I have Azure Pipelines set up for CI/CD for my modules to run tests and handle deployments to the PSGallery.
    • Once all tests are passed and I've verified that anything new has added appropriate tests, I merge it to master.
    • After a couple months of this, I tag the latest commit to master as a new version & assign a version number appropriately, then my CI/CD runs through tests one last time (automatically) before publishing the module to the PSGallery.
This is the process I follow for PSKoans, and it's the process I'm trying to get going for PSWordCloud at the moment. The latter is more complicated as it is written in C# and testing from the PS end is infuriating as it doesn't generate console output for the most part. I need to go through and setup XUnit testing infrastructure for that to work out well, but I'll get there and it'll end up similar to PSKoans on the whole except for the language used for development and testing.

Thanks! This gives me a nice insight, from which I can work out our version control strategy. (I’m a fan of PSKoans, nice work btw)