2017-10-13 8 views
2

私はgitlabをインストールしていますが、ドッカーエグゼキュータを使ってgitlab-runnerをセットアップしようとしています。すべてOKテストが実行を開始するまで、その後、私のプロジェクトがプライベートであり、彼らは何のHTTPアクセスが有効になっているないので、彼らが使用してクローン時に失敗:私はhttps://docs.gitlab.com/ee/ci/ssh_keys/README.html に見て、私のように、それを試してみることにしましたgitlab-runnerを取得する10.0.2 sshを使ってクローンを作成する

Running with gitlab-runner 10.0.2 (a9a76a50) 
    on Jupiter-docker (5f4ed288) 
Using Docker executor with image fedora:26 ... 
Using docker image sha256:1f082f05a7fc20f99a4ccffc0484f45e6227984940f2c57d8617187b44fd5c46 for predefined container... 
Pulling docker image fedora:26 ... 
Using docker image fedora:26 ID=sha256:b0b140824a486ccc0f7968f3c6ceb6982b4b77e82ef8b4faaf2806049fc266df for build container... 
Running on runner-5f4ed288-project-5-concurrent-0 via 2705e39bc3d7... 
Cloning repository... 
Cloning into '/builds/pmatos/tob'... 
remote: Git access over HTTP is not allowed 
fatal: unable to access 'https://gitlab.linki.tools/pmatos/tob.git': The requested URL returned error: 403 
ERROR: Job failed: exit code 1 

.gitlab-ci.yml開始:

image: fedora:26 

before_script: 
    # Install ssh-agent if not already installed, it is required by Docker. 
    # (change apt-get to yum if you use a CentOS-based image) 
    - 'which ssh-agent || (apt-get update -y && apt-get install openssh-client -y)' 
    # Run ssh-agent (inside the build environment) 
    - eval $(ssh-agent -s) 
    # Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store 
    - ssh-add <(echo "$SSH_PRIVATE_KEY") 
    # For Docker builds disable host key checking. Be aware that by adding that 
    # you are suspectible to man-in-the-middle attacks. 
    # WARNING: Use this only with the Docker executor, if you use it with shell 
    # you will overwrite your user's SSH config. 
    - mkdir -p ~/.ssh 
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' 

... JOBS... 

I SSH_PRIVATE_KEY正しくセットアップなどが、問題は、プロジェクトのクローニングはbefore_script前に起こるということです。私はその後、-v /home/pmatos/gitlab-runner_ssh:/root/.sshでコンテナを起動しようとしましたが、依然としてクローニングはHTTPを使用しようとしています。コンテナにsshを強制的にクローンすることはできますか?

答えて

0

私はその後-v /home/pmatos/gitlab-runner_ssh:/root/.sshでコンテナを起動しようとしましたが、まだクローニングが可能な場合は、少なくとも試しHTTP

を使用しようとしていますあなたのコンテナ内の任意のHTTPS URLの使用SSHのいずれかのクローンになるだろう(SSHユーザがgitであると仮定)

git config --global url.ssh://[email protected] https:// 

を追加します。

+1

残念ながら、 'gitlab-runner'が新しいパイプラインビルドを開始するたびに新しいコンテナが作成されるため、これは不可能です。 –

関連する問題