我的CI找不到堆栈,我不知道为什么。我使用以下.gitlab-ci.yml文件为Haskell Stack项目设置gitlab。我从另一个问题声称它起了作用那里拿的。
image: haskell:8.6.5
cache:
paths:
- .stack
- .stack-work
- target
test:
stage: test
script:
- ghc --version
- stack --system-ghc build
- stack test
然而,它失败了,并报告了(下面是完整的输出):
bash: line 96: ghc: command not found
ERROR: Job failed: exit status 1
很明显,ghc是失踪的,但我想这是在图像haskell:8.6.5
上出现的,不是吗?
我尝试过替代图像,如image: fpco/stack-build:lts-11.15
,没有任何运气(报告,bash: line 96: stack: command not found
)。
我最好的猜测是,我错过了一个关键的步骤,以确保ghc
和stack
在我使用的图像上,但我不知道它是什么。那我错过了什么?
编辑:完全错误输出
Running with gitlab-runner 13.2.2 (a998cacd)
on karson: Ubuntu 20.04 LTS Shared q_B8_V-j
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:00
Running on karson...
Getting source from Git repository
00:01
Fetching changes with git depth set to 50...
Initialized empty Git repository in /var/lib/gitlab-runner/builds/q_B8_V-j/0/fromager/cheesecloth/MicroRAM/.git/
Created fresh repository.
Checking out 4d7e065d as 39-continuous-integration...
Skipping Git submodules setup
Restoring cache
00:00
Checking cache for default...
Runtime platform arch=amd64 os=linux pid=4053876 revision=a998cacd version=13.2.2
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted.
Successfully extracted cache
Executing "step_script" stage of the job script
00:00
$ ghc --version
bash: line 96: ghc: command not found
ERROR: Job failed: exit status 1
发布于 2021-01-13 07:14:07
在输出日志中,您使用的是壳执行器而不是docker执行器,这就是为什么image
标记在这里没有效果的原因。
要解决的选择是:
docker
执行器(https://docs.gitlab.com/runner/install/docker.html),并确保使用tags
指定要用于作业的运行程序。(您可能不一定需要重新安装流道,但只需将流道安装在shell流道旁边,但您需要确保正确使用tags
,以确定您是否想使用shell转轮或对接转轮)。更新:确保您为这项工作选择正确的跑步者:
在步骤5中,当登记运行器时,您可以提供与运行程序相关联的标记。如果您有足够的权限,还可以更改GitLab UI中的标记:
gitlab.com -> group -> settings -> CI/CD -> runner settings
注意,运行标记在config.toml文件中是不可更改的。
例如,现在可以用docker-internal
标记运行器,然后只在这个运行程序上运行作业,在gitlab-ci.yml文件中添加标记:- docker-internal
:
test:
stage: test
script:
- ghc --version
- stack --system-ghc build
- stack test
tags:
- docker-internal
https://stackoverflow.com/questions/65693354
复制