需求
- 搭建了docker,想要让jenkins拉取gitlab代码
过程
-
新建任务
-
输出名称,选择 free style
3. 选择git输出项目
- 这个地方有个坑,如果输出localhost:8090,会报错
无法连接仓库:Command "git ls-remote -h -- http://localhost:8090 HEAD" returned status code 128:
stdout:
stderr: fatal: unable to access 'http://localhost:8090/': Failed to connect to localhost port 8090: Connection refused
- 所以一定要用
http://host.docker.internal:8090
- 配置账号
- 配置的方式有很多,用户名和密码、SSH等,不过多介绍。
- 点击保存,进行构建测试。
- 成功
总结
docker容器中的jenkins访问gitlab,不是docker间访问,我还尝试了使用,docker --link创建容器,结果并不能解决问题。
最后想到,应该访问宿主机的端口,才能达到目的。