当 gitlab-runner
使用 docker
执行器和我构建的镜像时,其中一个 gitlab
ci
作业出现了错误。
以下是在 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
时,这些行不会出现错误
这是镜像19950818/banu-terraform-ansible-cicd
的Dockerfile
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
这一行是否导致了错误。
set -xv
;虽然不完美,但它确实可以帮助显示更多用于调试的行。 - ctwheels