在带有Chocolatey的Windows上安装gitlab-runner

时间:2019-02-27 14:07:34

标签: gitlab-ci gitlab-ci-runner chocolatey

我正在尝试使用chocolatey在Windows上部署gitlab-runner。

我的意图是将gitlab-runner安装在E:\gitlab-runner目录中,自动注册运行器并将其作为服务启动

我执行了以下一行:

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

我得到以下输出:

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

已在E:\gitlab-runner中正确下载了gitlab-runner.exe,但未完成注册,也未创建任何服务。还可以在E:\gitlab-runner中下载register_example.ps1。

我的安装过程有什么问题?我需要使用自定义值修改register_example.ps1吗?

2 个答案:

答案 0 :(得分:1)

不幸的是,此特定程序包未在描述中提供示例来说明如何正确传递程序包参数。但是,您可以在此处找到更多信息以及如何执行此操作的示例:

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

我相信您将需要类似于以下命令:

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

否则,将忽略您尝试传递的参数。

答案 1 :(得分:0)

@Gary Ewan Park提供的命令虽然很好,但不足以完全管理Windows上的gitlab-runner安装。

安装过程

  1. 使用Chocolatey安装gitlab-runner

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

    它将在E:\gitlab-runner directory中下载一个exe,在gitlab-runner中创建服务,并在同一目录中创建register_example.ps1

  2. 使用所需的值修改register_example.ps1并在register.ps1中重命名

  3. 执行register.ps1在Gitlab服务器中注册跑步者。还会在执行config.toml脚本的目录中创建一个register.ps1

  4. 默认情况下,gitlab-runner服务的可执行文件路径为

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

    这对我不利。要在命令行中更改可执行路径,请参见此thread

    之后,该服务已启动并正在运行,并且运行程序已在Giltab服务器中正确注册。

升级过程

  1. 停止gitlab-runner服务(否则,巧克力崩溃,因为该文件已存在时无法创建文件)

  2. 执行巧克力升级

    choco upgrade -y gitlab-runner --source https://mynexusproxy/repository/chocolatey-org/
    
  3. 启动gitlab-runner服务