代码改变世界

天行健,君子以自强不息

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

摘要

这是在Windows中摸索Gitlab Runner的第一个坑:默认的值是“pwsh”。

错误提示:

Running with gitlab-runner 16.9.0 (656c1943)
  on Alice-WIndows-11 ********, system ID: s_**********
Preparing the "shell" executor 00:00
Using Shell (pwsh) executor...
Preparing environment 00:00
ERROR: Job failed (system failure): prepare environment: failed to start process: exec: "pwsh": executable file not found in %PATH%. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information

错误的地方

config.toml的原始配置

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "wz94"
  url = "https://code.com/"
  token = "id7_cuyyyA-xWzNhtdsB"
  executor = "shell"
  shell = "pwsh" # 初始值是这个,正确应该修改成:shell = "powershell"  
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]

1、网上有人说,删除这一行

或者改为

shell = ""

这样就会造成流水线无法获取到.gitlab-ci.yml中定义的变量。

正确做法

shell = "powershell"

本文在说什么?

说的是Gitlab Runner的config.toml文件,正确文件完整展示如下:

concurrent = 1
check_interval = 0
connection_max_age = "15m0s"
shutdown_timeout = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "Alice-WIndows-11"
  url = "https://gitlab.********.cn"
  id = 37
  token = "********-******************"
  token_obtained_at = 2024-04-11T16:39:42Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "shell"
  shell = "powershell"
  [runners.cache]
    MaxUploadedArchiveSize = 0

未完待续……

posted on 2024-04-13 22:55  终南山人  阅读(286)  评论(0)    收藏  举报