【问题标题】:Installation gitlab-runner on windows with chocolatey在带有巧克力的 Windows 上安装 gitlab-runner
【发布时间】:2019-07-21 06:47:33
【问题描述】:

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

我的意图是在E:\gitlab-runner目录下安装gitlab-runner,自动注册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,但是注册没有完成,也没有创建服务。一个register_example.ps1也在E:\gitlab-runner下载。

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

【问题讨论】:

  • 您能显示您尝试使用的确切安装命令吗?
  • 抱歉,我在帖子中忘记了那部分。我编辑了它。

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


【解决方案1】:

@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 服务器中注册运行器。它还将在您执行register.ps1 脚本的目录中创建一个config.toml

  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 服务

【讨论】:

  • 我很惊讶需要手动停止服务。由于包中 ChocolateyBeforeModify.ps1 文件的内容,应该注意这一点。
【解决方案2】:

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

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/

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

【讨论】:

  • 安装服务时出错: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'.
  • 你能分享日志文件吗?
  • C:\ProgramData\chocolatey\logs\chocolatey.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.。你知道我可以在哪个日志中看到更多详细信息吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多