I'm trying to use the continuous integration system that Gitlab CI offers to build skills and automatically deploy my repo following a git push my local.
But here are weeks that I can not find the solutions that I decided to use.
Files :
- ./.gitlab-ci.yml
- ./deploy.sh
gitlab-ci.yml
image: ubuntu:latest
before_script:
- apt-get install -y
- apt-get update -y
stages:
- deploy
deploy_staging:
stage: deploy
script:
- echo "Deploy to staging server"
- expect ./deploy.sh
environment:
name: staging
url: my.site.com
only:
- master
deploy.sh
#!/usr/bin/expect -f
spawn ssh username@host "cd www && git pull https://Username:[email protected]/My/privaterepo.git"
expect "password:"
send "myPassword\n";
interact
My problem is that I often have an error like this :
- expect ./deploy.sh
/bin/bash: line 79: expect: command not found
I had other errors when I enter my sh file from gitlab-ci.yml :
- sh ./deploy.sh ( or bash ./deploy.sh )
./deploy.sh: 6: ./deploy.sh: spawn: not found
./deploy.sh: 8: ./deploy.sh: expect: not found
./deploy.sh: 9: ./deploy.sh: send: not found
./deploy.sh: 11: ./deploy.sh: interact: not found
and when in my terminal of my computer I run expect ./deploy.sh, the deployment is working properly.
i also tried in the before_script to install expect :
- apt-get update expect -y
But I had a question for one package "tzdata" to choose my country. but I can not intervene in the script.
My goal is that every git push of my local, that gitlab it launches a git pull and the update of the code on my site of preprod and prod then (that I intend to block then with a "when : manual "in another task).
Would you have a solution to help me solve this problem because I think it does not take a lot of things that I do not understand ?
Thank you !