我想将ma测试应用程序从本地存储库部署到gitlab存储库,并使用gitlab ci将其推送到我的远程服务器。 SSH连接正常,gitlab CI显示作业已通过,但远程服务器上的代码未更新。
我在/home/repos/testDeploy.git
中进行了裸仓库文件文件夹位于:/home/example.com/web/testDeploy
我添加了
我的.gitlab-ci.yml文件
stages:
- deploy
deployment:
stage: deploy
environment:
name: production
url: http://www.example.com/testDeploy
only:
- master
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- chmod 600 ~/.ssh/id_rsa_gitlab && chmod 700 ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- git remote add production ssh://user@server:port/home/repos/testDeploy.git
- git push -f production master
- echo "Deployed to production!"
另外,我有接收后挂钩:
#!/bin/sh
git --git-dir=/home/repos/testDeploy.git --work-tree=/home/example.com/web/testDeploy checkout -f
我在本地仓库中进行更改,提交并推送到Origin master到gitlab。作业已通过,但如上所述,远程服务器上的文件未更新。
gitlab作业的输出为:
Fetching changes...
HEAD is now at 595db67 as
Checking out 595db67b as master...
Skipping Git submodules setup
$ which ssh-agent || ( apt-get update -y && apt-get install openssh- client -y )
/usr/bin/ssh-agent
$ eval $(ssh-agent -s)
Agent pid 40589
$ chmod 600 ~/.ssh/id_rsa_gitlab && chmod 700 ~/.ssh
$ [[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
$ git branch
* (HEAD detached at 595db67)
master
production
$ git push -f production master
Everything up-to-date
$ echo "Deployed to production!"
Deployed to production!
Job succeeded
我做错了什么?有人可以帮我解决一下吗?谢谢您的回答。