gitlab-ci - 部署时 CD gitlab 作业的问题
问题描述
我正在尝试设置广告 CD 作业,以便在主更改时部署在实时生产中,并在登台分支更改时部署在登台中。
我.gitlab-ci.yml
的如下
before_script:
- apt-get update -qq
- apt-get install -qq git
# Setup SSH deploy keys
- 'which ssh-agent || ( apt-get install -qq openssh-client )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
deploy_live:
type: deploy
environment:
name: Live
url: xxxxx.xxxxx
script:
- ssh xxxx@0.0.0.0 -p 11111 "cd /www/xxx/public && git checkout master && git pull origin master && exit"
only:
- master
deploy_staging:
type: deploy
environment:
name: staging
url: staging.xxxx.xxxx
script:
- ssh xxx@0.0.0.0 -p 11111 "cd /www/xxx/public && git checkout staging && git pull origin staging && exit"
only:
- staging
我更改了一些连接数据
当我改变一些东西,并且工作被扔进管道时,我得到了这个:
Running with gitlab-runner 14.0.0-rc1 (19d2d239)
on docker-auto-scale ed2dce3a
feature flags: FF_SKIP_DOCKER_MACHINE_PROVISION_ON_CREATION_FAILURE:true
Resolving secrets
00:00
Preparing the "docker+machine" executor
00:35
Using Docker executor with image ruby:2.5 ...
Pulling docker image ruby:2.5 ...
Using docker image sha256:13fd310aa3adfd5db7b986cc64b5b6816bea774cf51de468d917e6ef038b418f for ruby:2.5 with digest ruby@sha256:d273723056dda84bda81454eb42743c6c29fdf2c2d4d42bddf8e3dca8bb99aa4 ...
Preparing environment
00:02
Running on runner-ed2dce3a-project-27561610-concurrent-0 via runner-ed2dce3a-srm-1624167534-5f218231...
Getting source from Git repository
00:13
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/rankia/portugal/.git/
Created fresh repository.
Checking out 086ab265 as master...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:05
Using docker image sha256:13fd310aa3adfd5db7b986cc64b5b6816bea774cf51de468d917e6ef038b418f for ruby:2.5 with digest ruby@sha256:d273723056dda84bda81454eb42743c6c29fdf2c2d4d42bddf8e3dca8bb99aa4 ...
$ apt-get update -qq
$ apt-get install -qq git
$ which ssh-agent || ( apt-get install -qq openssh-client )
/usr/bin/ssh-agent
$ eval $(ssh-agent -s)
Agent pid 266
$ ssh-add <(echo "$SSH_PRIVATE_KEY")
Identity added: /dev/fd/63 (ansible-generated on QtF-rankia)
$ mkdir -p ~/.ssh
$ [[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
/bin/bash: line 133: gt: command not found
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1
解决方案
没有这样的命令>
。它看起来像是重定向操作 ( >
) 的 HTML 转义。我猜你是从一些在线资源中复制了这行代码,并且在路上有些东西被破坏了。
长话短说,将 a 替换为>
a>
就可以了:
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
推荐阅读
- javascript - 按日期时间降序和升序排列的firebase顺序
- javascript - 我如何使 QuerySelectorAll() 选择所有 html 标签并通过访问 html 标签的索引进行更改
- javascript - 如何从选定的复选框传递值
- apache-camel - 如何在Apache Camel中以间隔时间开始一条到另一条的路线
- python - 无法在 docker 中运行的浏览器中打开页面
- json - JSON对象的MQTT数据格式
- tableau-api - 在 Tableau 中过滤 Tableau 度量名称
- java - 我们如何编写模拟时钟的角度表达式?
- swift - 异步数据加载迅速
- android - 支持多种构建类型的华为 IAP