Use Case: #Script for CI automation?

We’re looking to update our CI/CD pipeline to orchestrate the build, deployment, packaging and testing of micro services. As part of this we need to do common things such as file management, downloads, software installation, configuration (local files & cloud config via API calls) run tests via nunit console, log & report results, start/stop services etc.

We already have a lot of powershell scripts which are automated with TeamCity, but because our architecture is quite simple, based around a single monolithic web application, our scripts are fairly basic. Once we move to micro services we’ll have a lot more pieces: multiple apps (containers) and multiple test assemblies and other artifacts etc.

We’re looking to roll out our own CI automation system based on a yaml file which describes the automation steps using various pre-made functions such as copying files, updating xml config, installing services, running tests etc. and at the same time we’re looking at alternatives such as Cake but my question is, could this be a use-case for #Script?

The reason for rolling our own is that we’re often working on small units of work at the same time so we need to spin up often many replica test environments at once. This can cost a lot for us when using cloud services (especially for not-for-proft orgs) so we have a bunch of on-premise servers we can use to spin-up VMs. But this prevents us from easily using existing cloud-based CI services.

We’re looking for an open-source scripting environment that we can use to build automation tasks which ideally will run on any environment and allow us to record results and post back to TeamCity. We can also take advantage of Octopus Deploy for deployment tasks. Both of which have APIs.

I used to use node, but I’ve basically switched to using #Script Scripts for all my cross-platform automation tasks as I find the real-time feedback of web watch much more productive to create scripts which is easily run with web run.

#Script is useful when you need a lot of logic in your scripts like copying files, replacing text contents, making HTTP API calls, parsing JSON, needing lots of custom logic to run different commands, esp. useful for App logic that needs to hit an RDBMS, but if I only need to run shell commands I just write them in bash as it has access to all Linux utils like rsync and using SSH for remote deployment. The bash scripts are cross-platform and can be run in Windows using WSL’s bash, e.g:

$ bash deploy.sh

Although #Script isn’t used as part of our build solution and I was never fond of using an external build tool to build our solutions and create packages and have continued to rely on msbuild .projs to do the compilation + packaging of solutions and TeamCity to handle the over all orchestration tasks and project dependency triggering and custom tasks like NuGet restore, run tests, publish packages, etc.