【发布时间】:2016-12-22 21:48:02
【问题描述】:
所以,我在企业版上运行 GitLab CI 来构建我的项目,然后部署成功。
我有两个问题:
1. 我不能 git push 我的分支到安全的 SSH 远程。
2. 如何强制它仅在成功构建时部署?
这是我目前的配置:
stages:
- build
- deploy
services:
- mysql:latest
variables:
MYSQL_DATABASE: el_duderino
MYSQL_ROOT_PASSWORD: mysql_strong_password
node:
image: monostream/nodejs-gulp-bower
stage: build
script:
- npm install
- bower install --allow-root
- gulp
migrations:
image: eboraas/laravel
stage: build
script:
- composer install
- cp .env.testing .env
- php artisan key:generate
- php artisan migrate --force
- echo "Done!"
deploy_test:
stage: deploy
script:
- echo "Deploy to test server."
- git remote set-url test ssh://git@10.16.0.148/var/repo/subPortalTest.git
- git push test master
environment:
name: Test
url: http://10.16.0.148/
only:
- master
我的deploy_test 作业失败并返回以下内容:
主机密钥验证失败。
致命:无法从远程存储库读取。
请确保您拥有正确的访问权限和存储库 存在。
【问题讨论】:
-
Gitlab 提供了一个将启用 ssh-agent 的 SSH 密钥添加到管道的示例。您需要在 Gitlab 的 CI 配置中部署目标服务器的私有 SSH 密钥作为私有变量。
标签: git continuous-integration gitlab