docker - Gitlab Runner折叠了docker执行器的多行命令
问题描述
当使用执行程序和我构建的图像之一时,我在其中一项gitlab
ci
作业中收到此错误。gitlab-runner
docker
这是失败的工作gitlab-ci.yml
image:
name: 19950818/banu-terraform-ansible-cicd
.
.
.
create-ssh-key-pair:
stage: create-ssh-key-pair
script:
- pwd
- mkdir -p ~/.ssh
# below lines gives the error
- |
# !/bin/bash
FILE=~/.ssh/id_rsa
if [ -f "$FILE" ]; then
echo "$FILE exists."
else
ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa 2>/dev/null <<< y >/dev/null
fi
但是当执行者是时,这些行不会出错shell
这是Dockerfile
图像的19950818/banu-terraform-ansible-cicd
FROM centos:7
ENV VER "0.12.9"
RUN yum update -y && yum install wget -y && yum install unzip -y
RUN yum install epel-release -y && yum install ansible -y
RUN wget https://releases.hashicorp.com/terraform/${VER}/terraform_${VER}_linux_amd64.zip
RUN unzip terraform_${VER}_linux_amd64.zip
RUN mv terraform /usr/local/bin/
RUN rm -rf terraform_${VER}_linux_amd64.zip
有人可以告诉我发生了什么以及如何克服这个问题吗?
我的怀疑是ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa 2>/dev/null <<< y >/dev/null
线路导致错误。
解决方案
更改- |
为- >
。
推荐阅读
- powershell - 有没有办法将 VS 2019 的 Developer Powershell 添加为 VSCode 中的集成终端?
- spring - 如何将异常定向到 Spring Integration 中的自定义错误通道?
- c - 如何使用 Bison 打印生成的解析树?
- r - 通过R中的多列获取前n个组合
- algorithm - 用 O(log(n)) 实现最近向量搜索的算法
- go - 单值上下文中的多值“crypto/rand”.Int()
- deep-learning - 特定数据集的最优模型
- vim - 如何从前导键输入变量,并在 vim 中执行命令?
- c++ - 如何将字符与字符串进行比较?
- php - 将 RSA 解密 C# 代码转换为 Php 代码