0

I'm trying to deploy gitlab-runner on windows using chocolatey.

My intention is to install gitlab-runner in E:\gitlab-runner directory, automatically register the runner and start it as a service

I executed the following line :

choco install -y gitlab-runner /InstallDir E:\gitlab-runner /Service   --source https://mynexusproxy/repository/chocolatey-org/

and I got the following output :

Chocolatey v0.10.11
Installing the following packages:
gitlab-runner;/InstallDir;E:\gitlab-runner;/Service
By installing you accept licenses for the packages.
Progress: Downloading gitlab-runner 11.8.0... 100%

gitlab-runner v11.8.0
gitlab-runner package files install completed. Performing other installation steps.
Using previous gitlab-runner install path: e:\gitlab-runner
Installing x64 bit version
Added C:\ProgramData\chocolatey\bin\gitlab-runner.exe shim pointed to 'e:\gitlab-runner\gitlab-runner.exe'.
 The install of gitlab-runner was successful.
  Software install location not explicitly set, could be in package or
  default install location if installer.
Second path fragment must not be a drive or UNC name.
Parameter name: path2

The gitlab-runner.exe is correctly downloaded in E:\gitlab-runner but the register is not done and no service is created. A register_example.ps1 is also download in E:\gitlab-runner.

What's wrong with my installation procedure ? Do I need to modify the register_example.ps1 with custom values ?

Nicolas Pepinster
  • 2,899
  • 14
  • 31

2 Answers2

1

It is unfortunate that this particular package does not provide an example in the description to show how to correctly pass the package parameters. However, you can find more information, and examples of how to do this here:

https://chocolatey.org/docs/how-to-parse-package-parameters-argument

I believe you are going to want a command similar to the following:

choco install -y gitlab-runner --params="'/InstallDir=E:\gitlab-runner /Service'"   --source https://mynexusproxy/repository/chocolatey-org/

Otherwise, the parameters that you are trying to pass in will simply be ignored.

Gary Ewan Park
  • 13,805
  • 4
  • 29
  • 53
  • I got an error during the service installation : `Installing gitlab-runner service ERROR: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Runtime platform The install of gitlab-runner was NOT successful. Error while running 'C:\ProgramData\chocolatey\lib\gitlab-runner\tools\chocolateyInstall.ps1'.` – Nicolas Pepinster Feb 27 '19 at 15:59
  • Are you able to share the log file? – Gary Ewan Park Feb 27 '19 at 16:02
  • the log in `C:\ProgramData\chocolatey\logs\chocolatey.log` refers to an other log `2019-02-27 16:58:23,765 6656 [ERROR] - - gitlab-runner (exited -1) - Error while running 'C:\ProgramData\chocolatey\lib\gitlab-runner\tools\chocolateyInstall.ps1'. See log for details.`. Do you know in which log I can see more details ? – Nicolas Pepinster Feb 28 '19 at 08:50
0

The command provided by @Gary Ewan Park is good but it's not sufficient to fully manage the gitlab-runner installation on Windows.

Installation procedure

  1. Install the gitlab-runner with chocolatey

    choco install -y gitlab-runner --params="'/InstallDir=E:\gitlab-runner /Service'"   --source https://mynexusproxy/repository/chocolatey-org/
    

    it will download an exe in the E:\gitlab-runner directory, create a service gitlab-runner and create a register_example.ps1 in the same directory.

  2. Modify the register_example.ps1 with your desired value and rename it in register.ps1

  3. Execute register.ps1 to register the runner in your Gitlab server. It will create also a config.toml in the directory where you execute the register.ps1 script.

  4. Per default, the gitlab-runner service executable path is

    E:\gitlab-runner\gitlab-runner.exe run --working-directory C:\Windows\system32 --config C:\Windows\system32\config.toml --service gitlab-runner --syslog 
    

    which was not good for me. To change the executable path in command line, see this thread.

    After that, the service is up and running and the runner is correctly registered in the Giltab Server.

Upgrade procedure

  1. stop the gitlab-runner service (otherwise chocolatey crash because it cannot create a file when that file already exists)

  2. execute the upgrade with chocolatey

    choco upgrade -y gitlab-runner --source https://mynexusproxy/repository/chocolatey-org/
    
  3. start the gitlab-runner service

Wai Ha Lee
  • 7,664
  • 52
  • 54
  • 80
Nicolas Pepinster
  • 2,899
  • 14
  • 31
  • I am surprised that the manual step to stop the service is required. This should be taken care of due to the contents of the chocolateyBeforeModify.ps1 file within the package. – Gary Ewan Park Mar 13 '19 at 13:16