首页 > 解决方案 > 使用 Vagrant 配置 Gitlab CI VirtualBox Runner

问题描述

1) 上下文

我正在使用 Gitlab 的 VirtualBox 运行器(Gitlab 版本 10.6.3)运行构建管道。当我手动创建一个基本映像(例如my-base-vm)时,构建在1-nGitlab-CI 创建的克隆上完美运行。

2) 观察到的错误

但是,当我想使用 Vagrant(版本 2.2.2)配置基本映像时,我的工作的 Gitlab CI 构建输出显示以下内容:

Running with gitlab-runner 11.2.0 (35e8515d)
  on myproject-build-machine 1c8ab769
Using VirtualBox version 5.2.18_Ubuntur123745 executor...
Creating new VM...
ERROR: Preparation failed: ssh: handshake failed: read tcp 127.0.0.1:35542->127.0.0.1:34963: read: connection reset by peer
Will be retried in 3s ...
Using VirtualBox version 5.2.18_Ubuntur123745 executor...
Creating new VM...
ERROR: Job failed: execution took longer than 1h0m0s seconds

该图像基于基本图像ubuntu/bionic64

3) 配置

跑步者(从 克隆my-base-vm)似乎具有正确的 NAT 规则(输出VBoxManage showvminfo my-base-vm-runner-1c8ab769-concurrent-0):

NIC 1 Rule(0):   name = guestssh, protocol = tcp, host ip = 127.0.0.1, host port = 32805, guest ip = , guest port = 22
NIC 1 Rule(1):   name = ssh, protocol = tcp, host ip = 127.0.0.1, host port = 2222, guest ip = , guest port = 22

Gitlabconfig.toml配置了正确的用户名 +密码vagrant:vagrantVagrantfile

config.vm.provision "shell", inline: <<-SHELL
        sed -i 's/ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/g' /etc/ssh/sshd_config
        sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
        service ssh restart
    SHELL

标签: vagrantgitlabvirtualboxgitlab-ci-runner

解决方案


推荐阅读