首页 > 解决方案 > Gitlab Runner折叠了docker执行器的多行命令

问题描述

当使用执行程序和我构建的图像之一时,我在其中一项gitlab ci作业中收到此错误。gitlab-runnerdocker

这是失败的工作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线路导致错误。

标签: dockergitlab

解决方案


更改- |- >

另请参阅GitLab Runner 问题 #166


推荐阅读