【发布时间】:2018-07-25 10:37:42
【问题描述】:
所以我正在使用一个自托管的 GitLab 实例来尝试部署我的 Laravel 应用程序。我在 SSH 执行器上使用 v10+ GitLab 运行器。
这是我的.gitlab-ci.yml:
stages:
- deploy
deploy_develop:
stage: deploy
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- ssh-keyscan beta.beethovenworld.com > ~/.ssh/known_hosts
script:
- ssh -t nn2@beta.beethovenworld.com "chmod 400 ~/.ssh/id_rsa && cd /var/www/html && git pull origin develop -f && composer install --no-interaction --optimize-autoloader && php artisan key:generate && php artisan optimize && php artisan config:cache && php artisan route:cache && php artisan migrate"
environment:
name: beta
url: https://beta.beethovenworld.com
only:
- develop
如您所见,我使用 SSH 进入并执行这些操作。如果有更简洁的方法来编写这个.yml 文件,请告诉我。
错误:
From gitlab.beethovenworld.com:nn2/beethovenworld
* branch develop -> FETCH_HEAD
3c3ebf7..37f47cf develop -> origin/develop
error: Your local changes to the following files would be overwritten by merge:
resources/views/layouts/composer/manage.blade.php
Please, commit your changes or stash them before you can merge.
Aborting
Updating b4422e8..37f47cf
ERROR: Job failed: exit code 1
为什么我不能执行 git pull?我也上传了.git 文件夹到服务器。
如果我将git pull origin develop 替换为git log,则工作成功,我可以看到最新的git 更改。即使现在你也可以看到最新的 git commit。我做错了什么?
【问题讨论】: