我正在将gitlab-ci用于gitlab.com中托管的存储库,我无法从VCS存储库加载构建包。
我使用默认的gitlab-ci-multi-runner 1.1.3。
我的.gitlab-ci.yml:
image: php:5.6
services:
- mysql:latest
variables:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: test
before_script:
- mkdir ~/.ssh
- ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts
- bash gitlab-ci.sh > /dev/null
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install
- cp database/database.sqlite.example database/database.sqlite
- cp .env.test .env
- php artisan key:generate
- php artisan migrate:refresh --seed
test:
script:
- vendor/bin/phpunit
我的composer.json:
{
"name": "foo",
"description": "Foo",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"repositories": [
{
"type": "vcs",
"url": "git@gitlab.com:maneko/maravel-pages.git"
}
],
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"barryvdh/laravel-debugbar": "^2.1",
"squizlabs/php_codesniffer": "*",
"proengsoft/laravel-jsvalidation": "1.3.1",
"yajra/laravel-datatables-oracle": "~6.0",
"dimsav/laravel-translatable": "^5.5",
"laravelcollective/html": "5.2.*",
"maravel/pages": "dev-master"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/helpers.php"
]
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize",
"php artisan vendor:publish --provider=\"Proengsoft\\JsValidation\\JsValidationServiceProvider\" --tag=public --force"
]
},
"config": {
"preferred-install": "dist"
}
}
我收到与访问权限相关的错误,我不知道还能做什么。我读过在.gitlab-ci.yml文件中添加它但它不起作用:
ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts`
请帮忙吗?
感谢!!!
答案 0 :(得分:0)
gitlab-ci脚本作为不同的用户运行。如果你在本地创建了一个密钥并希望在你的gitlab-ci中使用它,你必须为gitlab-ci提供密钥。
一种方法是复制文件- cp ~/.ssh/gitlab.com ~/.ssh/id_rsa
这应该将您的本地密钥复制到gitlab运行器中。 请注意,SSH的HostKeyChecking有时会出现问题:
解决方案
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
会阻止这种情况。