在此上下文中不允许使用Gitlab CI YML Mapping值

时间:2018-04-18 10:34:52

标签: continuous-integration yaml gitlab gitlab-ci continuous-deployment

我想使用Gitlab CI在master中提交时将我的静态网站部署到ftp服务器。我在DevOps中没有经验,并尝试通过互联网上的教程来做到这一点。 我做了这个.gitlab-ci.yml文件

deploy:
    stage: deploy
    only:
        - master
        deploy:
  script:
    - apt-get update -qq && apt-get install -y -qq lftp
    - lftp -u ftp-login,ftp-pass ftp.server \
           -e "mirror -e -R -x .git -x excl.txt -x exclude-1 -x exclude-2 -x README.md -p ./ mysite/www/ ; quit"

但是gitlab向我显示了这个yml文件的错误。它表示在此上下文中不允许使用Mapping值。你能用这个档案打扰我吗?谢谢!

1 个答案:

答案 0 :(得分:0)

有相同的错误信息

(<unknown>): mapping values are not allowed in this context gitlabci

我的问题是:

查看文档:{​​{3}}

有时,脚本命令必须用单引号或双引号括起来。例如,包含冒号 (:) 的命令必须用单引号 (') 括起来。 YAML 解析器需要将文本解释为字符串而不是“键:值”对。

例如,此脚本使用冒号:

job:
  script:
    - curl --request POST --header 'Content-Type: application/json' "https://gitlab/api/v4/projects"

要被视为有效的 YAML,您必须将整个命令用单引号括起来。如果命令已经使用单引号,您应该尽可能将它们更改为双引号 ("):

job:
  script:
    - 'curl --request POST --header "Content-Type: application/json" "https://gitlab/api/v4/projects"'
相关问题