I'm trying to set up Gitlab CI/CD
on my Symfony
project using Deployer but i'm not able to do it.
When deployment is executed on my pipeline, i have an Operation timed out error
which mean that my config is wrong.
My gitlab-ci.yml :
image: php:7.4-cli-alpine
stages:
- deploy
before_script:
- apk add --update git openssh-client
- mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | ssh-add -
deploy:
stage: deploy
script:
- curl --show-error --silent https://getcomposer.org/installer | php
- php composer.phar install -d app/
- app/vendor/bin/dep deploy dev -vvv
environment:
name: prod
My hosts.yml inventory :
dev-server.com:
stage: dev
hostname: XX.XXX.XX.X
user: deployer
branch: develop
identityFile: ~/.ssh/gitlab
deploy_path: /var/www/recruitment_back
keep_releases: 1
My Gitlab pipeline error:
$ app/vendor/bin/dep deploy dev -vvv
✈︎ Deploying develop on XX.XXX.XX.X
• done on [dev-server.com]
➤ Executing task deploy:prepare
[dev-server.com] > export APP_ENV='prod'; echo $0
[dev-server.com] < ssh multiplexing initialization
[dev-server.com] < ssh: connect to host XX.XXX.XX.X port 22: Operation timed out
➤ Executing task deploy:failed
• done on [dev-server.com]
✔ Ok [0ms]
I've also added variable SSH_PRIVATE_KEY
in Gitlab CI/CD
settings and also added my public ssh key in authorized_keys
on my server.
The deployment working good when executed on my local machine.
What's wrong with my config ?
My Solution :
PRIVATE_KEY
in Gitlab variablesgit clone
operation executed by Deployerssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts
My gitlab-ci.yml:
If there is a better solution. Please let me know.