./deploy.sh在gitlab ci上不起作用 [英] ./deploy.sh not working on gitlab ci
问题描述
我的问题是我创建的bash脚本在gitlab上出现此错误 / bin / sh:eval:第88行:./deploy.sh:找不到 。下面是我的示例脚本 .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 whaty的错误。
All I want is to execute deploy.sh after docker push but unfortunately got this error about /bin/bash thingy.
我真的需要您的帮助。如果您能解决有关gitlab ci bash脚本的错误 / bin / sh:eval:第88行:./deploy.sh:找不到 。
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
基于高山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屋!