./deploy.sh 不适用于 gitlab ci [英] ./deploy.sh not working on gitlab ci
问题描述
我的问题是我创建的 bash 脚本在 gitlab 上出现此错误 "/bin/sh: eval: line 88: ./deploy.sh: not found".下面是我的示例脚本 .gitlab-ci.yml.
My problem is the bash script I created got this error "/bin/sh: eval: line 88: ./deploy.sh: not found" on gitlab. Below is my sample script .gitlab-ci.yml.
我怀疑 gitlab ci 不支持 bash 脚本.
I suspect that gitlab ci is not supporting bash script.
image: docker:latest
variables:
IMAGE_NAME: registry.gitlab.com/$PROJECT_OWNER/$PROJECT_NAME
DOCKER_DRIVER: overlay
services:
- docker:dind
stages:
- deploy
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
- docker pull $IMAGE_NAME:$CI_BUILD_REF_NAME || true
production-deploy:
stage: deploy
only:
- master@$PROJECT_OWNER/$PROJECT_NAME
script:
- echo "$PRODUCTION_DOCKER_FILE" > Dockerfile
- docker build --cache-from $IMAGE_NAME:$CI_BUILD_REF_NAME -t $IMAGE_NAME:$CI_BUILD_REF_NAME .
- docker push $IMAGE_NAME:$CI_BUILD_REF_NAME
- echo "$PEM_FILE" > deploy.pem
- echo "$PRODUCTION_DEPLOY" > deploy.sh
- chmod 600 deploy.pem
- chmod 700 deploy.sh
- ./deploy.sh
environment:
name: production
url: https://www.example.com
这也是我的 deploy.sh.
#!/bin/bash
ssh -o StrictHostKeyChecking=no -i deploy.pem ec2-user@targetIPAddress << 'ENDSSH'
// command goes here
ENDSSH
我只想在 docker push 之后执行 deploy.sh,但不幸的是得到了这个关于/bin/bash 的错误.
All I want is to execute deploy.sh after docker push but unfortunately got this error about /bin/bash thingy.
我真的需要你们的帮助.如果你能解决我关于 gitlab ci bash script got error "/bin/sh: eval: line 88: ./deploy.sh: not found"的问题,我将不胜感激.
I really need your help guys. I will be thankful if you can solve my problem about gitlab ci bash script got error "/bin/sh: eval: line 88: ./deploy.sh: not found".
推荐答案
docker:latest
基于 alpine linux,非常简约,默认没有安装很多.例如,ssh
不是开箱即用的,所以如果你想使用 ssh 命令,你需要先安装它.在您的 before_script
中,添加:
docker:latest
is based on alpine linux which is very minimalistic and does not have a lot installed by default. For example, ssh
is not available out of the box, so if you want to use ssh commands you need to install it first. In your before_script
, add:
- apk update && apk add openssh
这篇关于./deploy.sh 不适用于 gitlab ci的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!