I am getting this error for one of the gitlab ci jobs when the gitlab-runner is using docker executor and one of the images I built.
This is the job getting failed in 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
But these lines DON'T MAKE the error when the executor is shell
This is the Dockerfile for the image 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
Can someone please tell me what is happening and how to overcome this problem?
My doubt is ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa 2>/dev/null <<< y >/dev/null line cause the error.