we have a lumen application we move the project to GitLab we wanna pull the project if all is ok.
We add the two scripts:
.gitlab-ci.yml:
variables:
- All or variables
stages:
- test
- production
testing:
type: test
image: php:7.1
script:
- echo "ok"
#Production stage
production:
stage: production
before_script:
- mkdir -p ~/.ssh
- echo -e "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- bash .gitlab-deploy.sh
environment:
name: production
url: https://alpha.merci.network/
when: manual
our deploy script ".gitlab-deploy.sh" looks like:
#!/bin/bash
#Get servers list
set -f
string=$DEPLOY_SERVER
array=(${string//,/ })
#Iterate servers for deploy and pull last commit
for i in "${!array[@]}"do
echo "Deploy project on server ${array[i]}"
ssh ubuntu@${array[i]} "cd /var/www && git pull origin master"
done
We already add the configuration:
When we push changes to the repo/master we saw on the dashboard log the next error:
So what we are missing? Any advice?
I just change the for to this for make it work: