我想git clone https://github.com/org/project.git在CentOS盒子上做一个简单但是得到:
错误:请求的URL在访问https://github.com/org/project.git/info/refs时返回错误:401
致命:HTTP请求失败
它永远不会提示我输入我的用户名/密码,只是失败了.
我可以在我的Mac上拨打完全相同的电话没问题 - 我错过了什么?
我在我的Ubuntu OS上使用了2个容器:Gitlab-ce和gitlab-runner
容器名称是:gitlab_gitlab_1和gitlab_gitlab-runner_1
我通过访问我的gitlab应用程序 gitlab.localhost.com:801
我用这个命令成功注册了一个跑步者:
docker exec -it gitlab_gitlab-runner_1 gitlab-runner register --non-interactive --url http://gitlab_gitlab_1 --registration-token _wgMgEx3nBocYQtoi83c --executor docker --docker-image alpine:latest
Run Code Online (Sandbox Code Playgroud)
然后,当我开始工作时,我收到此错误消息:
Running with gitlab-runner 10.7.1 (b9bba623)
on 589a617ee407 12ba77f7
Using Docker executor with image alpine:latest ...
Pulling docker image alpine:latest ...
Using docker image sha256:3fd9065eaf02feaf94d68376da52541925650b81698c53c6824d92ff63f98353 for alpine:latest ...
Running on runner-12ba77f7-project-1-concurrent-0 via 01196621a827...
Cloning repository...
Cloning into '/builds/root/test'...
fatal: unable to access 'http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@gitlab.localhost.com/root/test.git/': Could not resolve host: gitlab.localhost.com
ERROR: Job failed: exit code 1
Run Code Online (Sandbox Code Playgroud)
在这两个容器中,我都可以访问主机名gitlab.localhost.com …
我设置了一个Gitlab服务器,需要使用gitlab-runner.exe运行Windows测试.
gitlab-runner的执行器设置为shell,config.toml看起来像
concurrent = 1
check_interval = 0
[[runners]]
name = "PC123"
url = "http://1.2.3.4/ci"
token = "cd2b093adc5ca09ea41ee4eadb0752"
executor = "shell"
[runners.cache]
Run Code Online (Sandbox Code Playgroud)
当测试在提交时生成时,它将失败
Cloning into 'C:/git/builds/ac70aeb9/0/test/myproject'...
fatal: unable to access 'http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@localhost/test/boundaries.git/': Failed to connect to localhost port 80: Connection refused
Run Code Online (Sandbox Code Playgroud)
我想问题是URL中的主机名"localhost",它指的是gitlab-runner所在的机器.当我在开始时设置服务器时,我使用'localhost'作为服务器主机名.这可能不是最好的主意.:)
在此期间我改变了这个"localgit",但URL没有调整,它仍然显示"localhost".(服务器重启,gitlab-runner servive重启).
可能是服务器的主机名存储在主机名仍然是我克隆的原始仓库中的某个位置localhost?.git/config显示正确的IP:
[remote "origin"]
url = http://1.2.3.4/test/myproject.git
Run Code Online (Sandbox Code Playgroud)
我发现了另一个问题(GitLab运行器无法通过http克隆存储库)提到了一种将其他主机添加到gitlab-runner的方法config.toml,比如
[runners.docker]
extra_hosts = ["ci.mygitlab:127.0.0.1"]
Run Code Online (Sandbox Code Playgroud)
但我必须使用shell执行者,而不是docker.
我已经在容器gitlab上运行docker。另外,我已经gitlab-runner安装在我的 Cenots7 机器上。运行器配置使用docker执行器。
配置文件
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "test"
url = "http://localhost"
token = "gQfiiD4PUyPs4TiXLX9-"
executor = "docker"
log_level = "debug"
pre_clone_script = "ls -la"
clone_url = "http://localhost/"
[runners.docker]
tls_verify = false
image = "node"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
# network_mode = "gitlab_default"
# pull_policy = "never"
[runners.cache]
[runners.cache.s3] …Run Code Online (Sandbox Code Playgroud)