使用Vagrant设置Gitlab CI VirtualBox Runner

时间:2019-01-24 23:52:12

标签: vagrant gitlab virtualbox gitlab-ci-runner

1)上下文

我正在使用Gitlab的VirtualBox运行程序(Gitlab版本10.6.3)运行构建管道。当我手动创建基础映像(例如my-base-vm)时,该构建可以在Gitlab-CI创建的1-n克隆上完美运行。

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

为Gitlab config.toml配置了正确的用户名和密码(vagrant:vagrant),而Vagrant文​​件规定了机器接受用户名和密码作为身份验证的方式(摘自Vagrantfile) :

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

0 个答案:

没有答案