在你的.gitlab-ci.yml中发现错误:根配置包含未知键:部署脚本环境。

问题描述 投票:0回答:1

当我提交下面的.yml文件时,得到以下错误。

在你的.gitlab-ci.yml中发现错误:root config包含未知键:部署脚本环境

variables:
  MAVEN_CLI_OPTS: " -s .m2/settings.xml --batch-mode"
  MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"

cache:
  paths:
    - .m2/repository/
    - target/

build:
  stage: build
  script:
    - mvn $MAVEN_CLI_OPTS compile

test:
  stage: test
  script:
    - mvn $MAVEN_CLI_OPTS test

deploy:
  stage: production
  before_script:
    - mkdir -p ~/.ssh
    - echo -e "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
    - chmod 600  ~/.ssh/id_rsa

    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

script:
    - bash ./gitlab-deploy/.gitlab-deploy.prod.sh

environment:

     name: production
     url: http://myurl.com:81

我正在尝试将一个Maven项目从GitLab部署到AWS EC2,请检查。

maven amazon-ec2 gitlab devops continuous-deployment
1个回答
0
投票

请仔细检查你的 deploy 工作,这一行看起来很可疑。

- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

你看那里有一个单引号?

© www.soinside.com 2019 - 2024. All rights reserved.