Base image: ubuntu:19.04 Added packages: openssh-client sshpass
906
Sometimes I need to run command on remote server, such as doing git operation.
.gitlab-ci.yml to use with GitLabPut the password in DEV_SSH_PASS variable using Settings -> CI / CD -> Variables.
variables:
DEV_SERVER_USER: "web"
DEV_SERVER_HOST: "dev.example.id"
DEV_SERVER_PORT: "22"
DEV_SERVER_WORKDIR: "/var/www/html/mygitproject"
deploy:development:
image: alamaby/ssh:0.1.0
stage: deploy
only:
- master
script:
- eval $(ssh-agent -s)
- shopt -s expand_aliases
- alias runssh="sshpass -e ssh -o StrictHostKeyChecking=no"
- export SSHPASS=${DEV_SSH_PASS}
- runssh -p ${DEV_SERVER_PORT} ${DEV_SERVER_USER}@${DEV_SERVER_HOST} "cd ${DEV_SERVER_WORKDIR} && git add -A && git stash save && git checkout master && git pull && git stash pop"
Content type
Image
Digest
Size
38.7 MB
Last updated
about 7 years ago
docker pull alamaby/ssh:0.1.0