chh*_*001 2 gitlab gitlab-ci gitlab-ci-runner
我写了一个非常简单的 .gitlab-ci.yml 如下:
image: horchen/vscode-ext-dev
job1:
script:
- echo "Hello World"
Run Code Online (Sandbox Code Playgroud)
只是回显Hello World,我想它应该可以在任何平台上运行。但 gitlab-ci 总是告诉我其中有语法错误。
Running with gitlab-runner 13.2.2 (a998cacd)
on nodejs-ci aPuhC2uZ
Preparing the "docker" executor
Using Docker executor with image horchen/vscode-ext-dev ...
Using locally found image version due to if-not-present pull policy
Using docker image sha256:17af24ad877daa656e102508585c7262585be04b05a75cc89833afcfe7403ebb for horchen/vscode-ext-dev ...
Preparing environment
Running on runner-apuhc2uz-project-1-concurrent-0 via cf9f41a14878...
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/horchen/vscode-rlcv/.git/
Checking out 93d3b0e1 as master...
Skipping Git submodules setup
Executing "step_script" stage of the job script
[: line 1: syntax error: unexpected end of file (expecting "then")
ERROR: Job failed: exit code 2
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么会报告这样的错误?
--------------- 追加数据 -------------------
实际上我确实是在Windows上开发的,但我检查了CR/LF样式,还检查了hexdump。并尝试在 webIDE 和 linux VIM 上编辑它,都没有在其中找到 ^M 。
Offset: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000: 69 6D 61 67 65 3A 20 68 6F 72 63 68 65 6E 2F 76 image:.horchen/v
00000010: 73 63 6F 64 65 2D 65 78 74 2D 64 65 76 0A 0A 61 scode-ext-dev..a
00000020: 66 74 65 72 5F 73 63 72 69 70 74 3A 0A 20 20 2D fter_script:...-
00000030: 20 22 72 6D 20 2A 2E 76 73 69 78 22 0A 0A 6A 6F ."rm.*.vsix"..jo
00000040: 62 31 3A 0A 20 20 73 63 72 69 70 74 3A 0A 20 20 b1:...script:...
00000050: 20 20 2D 20 65 63 68 6F 20 22 48 65 6C 6C 6F 20 ..-.echo."Hello.
00000060: 57 6F 72 6C 64 22 0A World".
Run Code Online (Sandbox Code Playgroud)
step_script作业阶段包括和before_script部分script。您的执行器正在尝试执行您的script部分,这导致了错误。
unexpected end of file (expecting "then")Windows 与 Linux 文件格式中经常会出现此错误。请参阅语法错误:文件结尾意外(需要“then”)。尝试将您的gitlab-ci.yml文件转换为具有 Linux 行结尾,看看是否可以解决问题。有许多工具可以执行此操作(请参阅上面的链接),包括Notepad++.
如果这是您的问题,那么您可能会遇到更大的问题:您是在 Windows 中进行开发并在 Linux 中运行代码吗?如果是这样,您可能需要设置 .gitattirbutes 文件以自动将 Windows EOL 字符转换为 Linux,反之亦然。请参阅如何更改行结束设置。
如果这不起作用,请尝试向管道中添加另一个不打印任何内容的作业。x=2只需在该部分添加类似的内容即可script。这可能会消除echo作为script错误来源的可能性。
为了安全起见,创建一个stages部分并将两个作业分配到同一阶段,如下所示:
stages:
- test
job2:
stage: test
script:
- x = 2
Run Code Online (Sandbox Code Playgroud)
如果这仍然没有帮助,那么我会开始怀疑你的 Docker 镜像:horchen/vscode-ext-dev。GitLab 可能正在尝试script从容器中的作业执行,这可能首先执行一些代码。您可能需要发布您的 Dockerfile 来解决该问题。
我还会怀疑 Dockerfile 调用的任何脚本的 EOL CRLF/LF 字符。
| 归档时间: |
|
| 查看次数: |
9635 次 |
| 最近记录: |