Answers: <p>You can specify that you want gitlab to execute your CI job on a windows machine using <a href="https://docs.gitlab.com/ee/ci/yaml/#tags" rel="nofollow noreferrer">tags</a>.</p>
  <p>Gitlab made Windows Shared Runners available as Beta in Jan 2020. <a href="https://about.gitlab.com/blog/2020/01/21/windows-shared-runner-beta/" rel="nofollow noreferrer">Their announcement</a> shows how to use the <code>tags</code> key in your <code>.gitlab-ci</code> file to specify Windows machines.
  You can also run in a docker container in windows:</p>
  <ul>
  <li><a href="https://docs.gitlab.com/runner/executors/docker.html#using-windows-containers" rel="nofollow noreferrer">https://docs.gitlab.com/runner/executors/docker.html#using-windows-containers</a></li>
  </ul>
  <p>For example, I was able to execute a simple &quot;hello world&quot; powershell script with the following job in <a href="https://gitlab.com/maltfield/cross-platform-python-gui/-/blob/91f0d9e31ed5c5cfdcd073accc1b3cc86a00df0b/.gitlab-ci.yml" rel="nofollow noreferrer">my <code>.gitlab-ci</code> file</a>:</p>
  <pre class="lang-yaml prettyprint-override"><code>windows:
    script: &quot;build/windows/buildExe.ps1&quot;
    tags:
      - shared-windows
      - windows
      - windows-1809
  </code></pre>
  <p>And here's the <a href="https://gitlab.com/maltfield/cross-platform-python-gui/-/blob/91f0d9e31ed5c5cfdcd073accc1b3cc86a00df0b/build/windows/buildExe.ps1" rel="nofollow noreferrer"><code>buildExe.ps1</code> powershell script</a> reference above:</p>
  <pre><code>Write-Host &quot;listing contents of C drive root&quot;
  Get-ChildItem -Path C:\ -Force
  
  Write-Host &quot;listing contents of cwd&quot;
  Get-ChildItem -Force
  </code></pre>
  <p>The above config produced the following output <a href="https://gitlab.com/maltfield/cross-platform-python-gui/-/jobs/574193500" rel="nofollow noreferrer">in my CI job</a>:</p>
  <pre><code>[0KRunning with gitlab-runner 12.9.0 (4c96e5ad)
  [0;m[0K  on windows-shared-runners-manager 6QgxEPvR
  [0;msection_start:1590842482:prepare_executor
  [0K[0K[36;1mPreparing the &quot;custom&quot; executor[0;m
  [0;m[0KUsing Custom executor with driver autoscaler dev (64a348d)...
  [0;mCreating virtual machine for the job...
  Virtual machine created!
  section_end:1590842624:prepare_executor
  [0Ksection_start:1590842624:prepare_script
  [0K[0K[36;1mPreparing environment[0;m
  [0;mRunning on PACKER-5E557E8E via 
  runner-6qgxepvr-wsrm-87cf700a3349de62a18e...
  section_end:1590842640:prepare_script
  [0Ksection_start:1590842640:get_sources
  [0K[0K[36;1mGetting source from Git repository[0;m
  [0;m[32;1mFetching changes with git depth set to 50...[0;m
  Initialized empty Git repository in C:/GitLab-Runner/builds/maltfield/cross-platform-python-gui/.git/
  [32;1mCreated fresh repository.[0;m
  [32;1mChecking out 91f0d9e3 as master...[0;m
  From https://gitlab.com/maltfield/cross-platform-python-gui
   * [new ref]         refs/pipelines/151176370 -&gt; refs/pipelines/151176370
   * [new branch]      master                   -&gt; origin/master
  git-lfs/2.8.0 (GitHub; windows amd64; go 1.12.2; git 30af66bb)
  
  [32;1mUpdating/initializing submodules...[0;m
  git-lfs/2.8.0 (GitHub; windows amd64; go 1.12.2; git 30af66bb)
  section_end:1590842661:get_sources
  [0Ksection_start:1590842661:restore_cache
  [0K[0K[36;1mRestoring cache[0;m
  [0;msection_end:1590842670:restore_cache
  [0Ksection_start:1590842670:download_artifacts
  [0K[0K[36;1mDownloading artifacts[0;m
  [0;msection_end:1590842677:download_artifacts
  [0Ksection_start:1590842677:build_script
  [0K[0K[36;1mRunning before_script and script[0;m
  [0;m[32;1m$ build/windows/buildExe.ps1[0;m
  listing contents of C drive root
  
  
      Directory: C:\
  
  
  Mode                LastWriteTime         Length Name                                                                  
  ----                -------------         ------ ----                                                                  
  d--hs-       12/11/2019   2:47 AM                $RECYCLE.BIN                                                          
  d--hs-        2/25/2020   8:52 PM                Boot                                                                  
  d--hsl       12/11/2019  10:29 AM                Documents and Settings                                                
  d-----        2/25/2020   8:16 PM                Git                                                                   
  d-----        5/30/2020  12:44 PM                GitLab-Runner                                                         
  d-----        2/25/2020   8:16 PM                GitLFS                                                                
  d-----        2/25/2020   8:34 PM                Go                                                                    
  d-----        9/15/2018   7:12 AM                PerfLogs                                                              
  d-r---        2/25/2020   8:35 PM                Program Files                                                         
  d-----        2/25/2020   8:27 PM                Program Files (x86)                                                   
  d--h--        2/25/2020   8:51 PM                ProgramData                                                           
  d--hs-        2/25/2020   8:10 PM                Recovery                                                              
  d--hs-       12/11/2019  10:28 AM                System Volume Information                                             
  d-----        2/25/2020   8:32 PM                tools                                                                 
  d-r---        5/30/2020  12:43 PM                Users                                                                 
  d-----        2/25/2020   8:38 PM                vcpkg                                                                 
  d-----        2/25/2020   8:51 PM                Windows                                                               
  -arhs-        2/25/2020   8:45 PM         408834 bootmgr                                                               
  -a-hs-        9/15/2018   7:09 AM              1 BOOTNXT                                                               
  -a-hs-        5/30/2020  12:41 PM     1073741824 pagefile.sys                                                          
  listing contents of cwd
  
  
      Directory: C:\GitLab-Runner\builds\maltfield\cross-platform-python-gui
  
  
  Mode                LastWriteTime         Length Name                                                                  
  ----                -------------         ------ ----                                                                  
  d--h--        5/30/2020  12:44 PM                .git                                                                  
  d-----        5/30/2020  12:44 PM                build                                                                 
  d-----        5/30/2020  12:44 PM                src                                                                   
  -a----        5/30/2020  12:44 PM            534 .gitlab-ci.yml                                                        
  -a----        5/30/2020  12:44 PM          35787 LICENSE                                                               
  -a----        5/30/2020  12:44 PM           1171 README.md                                                             
  -a----        5/30/2020  12:44 PM              6 requirements.txt                                                      
  
  
  section_end:1590842686:build_script
  [0Ksection_start:1590842686:archive_cache
  [0K[0K[36;1mSaving cache[0;m
  [0;msection_end:1590842694:archive_cache
  [0Ksection_start:1590842694:upload_artifacts_on_success
  [0K[0K[36;1mUploading artifacts for successful job[0;m
  [0;msection_end:1590842701:upload_artifacts_on_success
  [0K[32;1mJob succeeded
  [0;m
  </code></pre>
  <p>As for MacOS, gitlab currently doesn't support it natively.
  If this changes, updated answers are welcome.</p>
  <p>Other answers showing how to run MacOS inside a VM (eg using vagrant and libvirt) on a gitlab shared runner are very welcome :)</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-05-30T12:59:59.430Z
Answers: 2021-06-30T21:44:04.760Z
Answers: 2021-06-30T21:44:04.760Z
Answers: Michael Altfield
Body: <p>How can I specify the operating system in the <code>.gitlab-ci</code> file to indicate which underlying OS on which the <code>gitlab-runner</code> should be running when using the <a href="https://about.gitlab.com/pricing/" rel="nofollow noreferrer">2,000 minutes of free execution</a> in with gitlab.com shared runners in Google Cloud Platform?</p>
  
  <p>For context, Github's free account supports <a href="https://help.github.com/en/github/setting-up-and-managing-billing-and-payments-on-github/about-billing-for-github-actions" rel="nofollow noreferrer">2,000 free minutes</a> per month in "Github-hosted runners" for running <a href="https://github.com/features/actions" rel="nofollow noreferrer">Github Actions</a> in <a href="https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners" rel="nofollow noreferrer">Azure and MacStadium</a>. You can specify whether you want the build to happen in Linux, Windows, or MacOS via the <a href="https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on" rel="nofollow noreferrer"><code>runs-on</code> key</a> in the <a href="https://help.github.com/en/actions/configuring-and-managing-workflows" rel="nofollow noreferrer">github workflow yaml file</a>.</p>
  
  <p>What is the equivalent method for specifying that I want to run a CI/CD job in a specific OS on GCP in the <code>.gitlab-ci</code> file?</p>
  
Tags: <continuous-integration><gitlab><github><gitlab-ci-runner><workflow>
Title: How to specify 'os' for free gitlab runners ('runs-on' equivalent)
UserDisplayName: Michael Altfield
ThreadText: # How to specify 'os' for free gitlab runners ('runs-on' equivalent)
  
  (Asked by: username_0 on 2020-05-29)
  
  How can I specify the operating system in the `.gitlab-ci` file to indicate which underlying OS on which the `gitlab-runner` should be running when using the [2,000 minutes of free execution](https://about.gitlab.com/pricing/) in with gitlab.com shared runners in Google Cloud Platform?
  
  For context, Github's free account supports [2,000 free minutes](https://help.github.com/en/github/setting-up-and-managing-billing-and-payments-on-github/about-billing-for-github-actions) per month in "Github-hosted runners" for running [Github Actions](https://github.com/features/actions) in [Azure and MacStadium](https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners). You can specify whether you want the build to happen in Linux, Windows, or MacOS via the [`runs-on` key](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on) in the [github workflow yaml file](https://help.github.com/en/actions/configuring-and-managing-workflows).
  
  What is the equivalent method for specifying that I want to run a CI/CD job in a specific OS on GCP in the `.gitlab-ci` file?
  
  **Tags:** continuous-integration, gitlab, github, gitlab-ci-runner, workflow
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-05-30. Score: 1
  
  You can specify that you want gitlab to execute your CI job on a windows machine using [tags](https://docs.gitlab.com/ee/ci/yaml/#tags).
  
  Gitlab made Windows Shared Runners available as Beta in Jan 2020. [Their announcement](https://about.gitlab.com/blog/2020/01/21/windows-shared-runner-beta/) shows how to use the `tags` key in your `.gitlab-ci` file to specify Windows machines.
  You can also run in a docker container in windows:
  
  * <https://docs.gitlab.com/runner/executors/docker.html#using-windows-containers>
  
  For example, I was able to execute a simple "hello world" powershell script with the following job in [my `.gitlab-ci` file](https://gitlab.com/maltfield/cross-platform-python-gui/-/blob/91f0d9e31ed5c5cfdcd073accc1b3cc86a00df0b/.gitlab-ci.yml):
  
  ```yaml
  windows:
    script: "build/windows/buildExe.ps1"
    tags:
      - shared-windows
      - windows
      - windows-1809
  
  ```
  
  And here's the [`buildExe.ps1` powershell script](https://gitlab.com/maltfield/cross-platform-python-gui/-/blob/91f0d9e31ed5c5cfdcd073accc1b3cc86a00df0b/build/windows/buildExe.ps1) reference above:
  
  ```
  Write-Host "listing contents of C drive root"
  Get-ChildItem -Path C:\ -Force
  
  Write-Host "listing contents of cwd"
  Get-ChildItem -Force
  
  ```
  
  The above config produced the following output [in my CI job](https://gitlab.com/maltfield/cross-platform-python-gui/-/jobs/574193500):
  
  ```
  [0KRunning with gitlab-runner 12.9.0 (4c96e5ad)
  [0;m[0K  on windows-shared-runners-manager 6QgxEPvR
  [0;msection_start:1590842482:prepare_executor
  [0K[0K[36;1mPreparing the "custom" executor[0;m
  [0;m[0KUsing Custom executor with driver autoscaler dev (64a348d)...
  [0;mCreating virtual machine for the job...
  Virtual machine created!
  section_end:1590842624:prepare_executor
  [0Ksection_start:1590842624:prepare_script
  [0K[0K[36;1mPreparing environment[0;m
  [0;mRunning on PACKER-5E557E8E via 
  runner-6qgxepvr-wsrm-87cf700a3349de62a18e...
  section_end:1590842640:prepare_script
  [0Ksection_start:1590842640:get_sources
  [0K[0K[36;1mGetting source from Git repository[0;m
  [0;m[32;1mFetching changes with git depth set to 50...[0;m
  Initialized empty Git repository in C:/GitLab-Runner/builds/maltfield/cross-platform-python-gui/.git/
  [32;1mCreated fresh repository.[0;m
  [32;1mChecking out 91f0d9e3 as master...[0;m
  From https://gitlab.com/maltfield/cross-platform-python-gui
   * [new ref]         refs/pipelines/151176370 -> refs/pipelines/151176370
   * [new branch]      master                   -> origin/master
  git-lfs/2.8.0 (GitHub; windows amd64; go 1.12.2; git 30af66bb)
  
  [32;1mUpdating/initializing submodules...[0;m
  git-lfs/2.8.0 (GitHub; windows amd64; go 1.12.2; git 30af66bb)
  section_end:1590842661:get_sources
  [0Ksection_start:1590842661:restore_cache
  [0K[0K[36;1mRestoring cache[0;m
  [0;msection_end:1590842670:restore_cache
  [0Ksection_start:1590842670:download_artifacts
  [0K[0K[36;1mDownloading artifacts[0;m
  [0;msection_end:1590842677:download_artifacts
  [0Ksection_start:1590842677:build_script
  [0K[0K[36;1mRunning before_script and script[0;m
  [0;m[32;1m$ build/windows/buildExe.ps1[0;m
  listing contents of C drive root
  
      Directory: C:\
  
  Mode                LastWriteTime         Length Name                                                                  
  ----                -------------         ------ ----                                                                  
  d--hs-       12/11/2019   2:47 AM                $RECYCLE.BIN                                                          
  d--hs-        2/25/2020   8:52 PM                Boot                                                                  
  d--hsl       12/11/2019  10:29 AM                Documents and Settings                                                
  d-----        2/25/2020   8:16 PM                Git                                                                   
  d-----        5/30/2020  12:44 PM                GitLab-Runner                                                         
  d-----        2/25/2020   8:16 PM                GitLFS                                                                
  d-----        2/25/2020   8:34 PM                Go                                                                    
  d-----        9/15/2018   7:12 AM                PerfLogs                                                              
  d-r---        2/25/2020   8:35 PM                Program Files                                                         
  d-----        2/25/2020   8:27 PM                Program Files (x86)                                                   
  d--h--        2/25/2020   8:51 PM                ProgramData                                                           
  d--hs-        2/25/2020   8:10 PM                Recovery                                                              
  d--hs-       12/11/2019  10:28 AM                System Volume Information                                             
  d-----        2/25/2020   8:32 PM                tools                                                                 
  d-r---        5/30/2020  12:43 PM                Users                                                                 
  d-----        2/25/2020   8:38 PM                vcpkg                                                                 
  d-----        2/25/2020   8:51 PM                Windows                                                               
  -arhs-        2/25/2020   8:45 PM         408834 bootmgr                                                               
  -a-hs-        9/15/2018   7:09 AM              1 BOOTNXT                                                               
  -a-hs-        5/30/2020  12:41 PM     1073741824 pagefile.sys                                                          
  listing contents of cwd
  
      Directory: C:\GitLab-Runner\builds\maltfield\cross-platform-python-gui
  
  Mode                LastWriteTime         Length Name                                                                  
  ----                -------------         ------ ----                                                                  
  d--h--        5/30/2020  12:44 PM                .git                                                                  
  d-----        5/30/2020  12:44 PM                build                                                                 
  d-----        5/30/2020  12:44 PM                src                                                                   
  -a----        5/30/2020  12:44 PM            534 .gitlab-ci.yml                                                        
  -a----        5/30/2020  12:44 PM          35787 LICENSE                                                               
  -a----        5/30/2020  12:44 PM           1171 README.md                                                             
  -a----        5/30/2020  12:44 PM              6 requirements.txt                                                      
  
  section_end:1590842686:build_script
  [0Ksection_start:1590842686:archive_cache
  [0K[0K[36;1mSaving cache[0;m
  [0;msection_end:1590842694:archive_cache
  [0Ksection_start:1590842694:upload_artifacts_on_success
  [0K[0K[36;1mUploading artifacts for successful job[0;m
  [0;msection_end:1590842701:upload_artifacts_on_success
  [0K[32;1mJob succeeded
  [0;m
  
  ```
  
  As for MacOS, gitlab currently doesn't support it natively.
  If this changes, updated answers are welcome.
  
  Other answers showing how to run MacOS inside a VM (eg using vagrant and libvirt) on a gitlab shared runner are very welcome :)
  
  
  ---
  
  