部署时CD gitlab作业出现问题



我正在尝试设置ad 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 *ntStrictHostKeyChecking nonn" &gt; ~/.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 *ntStrictHostKeyChecking nonn" &gt; ~/.ssh/config
/bin/bash: line 133: gt: command not found
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1

没有这样的命令&gt;。它看起来像重定向操作(>(的HTML转义。我猜你是从一些在线资源中复制了这句话,结果有什么东西在路上被破坏了。

长话短说,把&gt换成>,你就可以了:

- '[[ -f /.dockerenv ]] && echo -e "Host *ntStrictHostKeyChecking nonn" > ~/.ssh/config'

最新更新