我们在部署过程中使用Doctrine迁移捆绑包更新数据库。目前,我们正在切换到Gitlab-CI。
问题:由于命令php sf doctrine:migrations:diff
的输出包含stderr,CI正在中止部署过程。
.gitlab-ci.yml的一部分:
deploy_live:
type: deploy
environment:
name: live
url: 1.2.3.4
script:
- ssh root@1.2.3.4 "cd /var/www/html/ && git pull origin master && exit"
- ssh root@11.2.3.4 "cd /var/www/html/ && composer install -n && exit"
- ssh root@1.2.3.4 "cd /var/www/html/ && php sf doctrine:migrations:diff --env=prod && exit"
- ssh root@1.2.3.4 "cd /var/www/html/ && php sf doctrine:migrations:migrate -n --env=prod && exit"
- 'ssh root@1.2.3.4 "cd /var/www/html/ && chown www-data:www-data . -R && exit"'
only:
- master
Gitlab CI的输出:
$ ssh root@1.2.3.4 "cd /var/www/html/ && php sf doctrine:migrations:diff --env=prod && exit"
#!/usr/bin/env php
In NoChangesDetected.php line 13:
No changes detected in your mapping information.
doctrine:migrations:diff [--configuration [CONFIGURATION]] [--db-configuration [DB-CONFIGURATION]] [--editor-cmd [EDITOR-CMD]] [--filter-expression [FILTER-EXPRESSION]] [--formatted] [--line-length [LINE-LENGTH]] [--check-database-platform [CHECK-DATABASE-PLATFORM]] [--db DB] [--em [EM]] [--shard SHARD] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
ERROR: Job failed: exit code 1
这可能是一个错误,但也许可以避免?
仅供参考:sf
是指向bin/console
的符号链接。
答案 0 :(得分:1)
我刚刚找到了解决方法:
gitlab-ci.yml
文件执行的命令移至script
到Shell脚本deploy.sh
gitlab-ci.yml
deploy_live:
type: deploy
environment:
name: live
url: 1.2.3.4
script:
- scp deploy.sh root@1.2.3.4:/var/www/html/
- ssh root@1.2.3.4 "cd /var/www/html/ && chmod +x deploy.sh && ./deploy.sh && exit"
only:
- master
deploy.sh
cd /var/www/html/
git add --all
git commit -m "changes"
git pull origin master
composer install -n
php sf doctrine:cache:clear-metadata --env=prod
php sf doctrine:migrations:diff --env=prod
php sf doctrine:migrations:migrate -n --env=prod
php sf cache:clear --env=prod
exit
答案 1 :(得分:0)
他们为这种情况添加了选项:--allow-no-migration
-您可以尝试吗?