I have a GitLab CI project set up to run a PowerShell Script that produces a report for the group it’s in. It looks like this:
report:
script:
pwsh --Command ./runme.ps1
pages: true
I want to put that yaml/script somewhere central, and then run it for various groups.
I can’t put it in a central repo and then trigger it, because that uploads it to the GitLab Pages for the central job.
I can’t use import or components for that, because only the .yml is shared, not any script files.
It looks like my best option is to move the code into the yml and set up pwsh as the default shell.
However, we use a Docker executor for executing pwsh. And it looks like the default shell has to be the same for all jobs that run on that executor. So does that mean we need to have separate executors for “Docker bash” and “Docker pwsh”, rather than having one executor for all Docker jobs, and having each job choose what shell it wants to use?
Hi there,
What do you mean by “default shell”? It depends on the docker image you are using.
You must have a different image that of course has a different shell. E.g. a ubuntu docker image for /bin/bash and some windows-based image for the powershell. This kinda implies, you will also have different hosts, i.e. different gitlab runners with different executors on it (obviously you cannot run windows-based docker images on linux host, and vice-versa is possible but then you need to switch the daemon mode on windows, so I am not sure if that’s doable - see here)
However, noone says that the whole pipeline is run by the same executor/runner. Each executor has labels. So you can label your job according to the environment it needs (=job will pick the shell it wants to use; yes - according to the label). That is considered best practice I believe. You can also have a default tag, and then override it per job.
Unless… you are doing some black magic and have installed cygwin with bash inside that windows-based docker image or whatnot… 
Not sure how did you execute your other jobs that require linux/bash so far?
I hope this helps somehow 
Hi,
powershell can be installed on Linux as well. No need for Windows. Gitlab Docker executor for Linux includes it. Docker executor | GitLab Docs
Yes, this is PowerShell on Linux, under Docker.
Turns out you need to set the default command line in the config.toml to be PowerShell as well as adding a CMD “pwsh” to the Docker setup.