GitLab流水线中Gomod Athens无法下载私有仓库依赖,出现404错误
解决Gomod Athens下载GitLab私有依赖404问题
错误信息
go: downloading gitlab.ea.com/group/repo v1.0.0
tools/buildhelper/main.go:20:2: gitlab.ea.com/group/repo@v1.0.0: reading http://gomods-athens-cc.cicd-maintenance-28024-production.svc.cluster.local/gitlab.ea.com/group/repo/@v/v1.0.0.zip: 404 Not Found
make: *** [deployment/gitlab-ci/build_all.make:22: prepare] Error 1
解决方案
验证私有仓库版本存在性
登录gitlab.ea.com/group/repo仓库,检查Tags页面是否存在v1.0.0标签。若缺失,执行以下命令创建并推送标签:git tag v1.0.0 git push origin v1.0.0配置Athens访问私有仓库的权限
- 在GitLab为Athens创建带
read_repository权限的专用访问令牌 - 将该令牌注入Athens服务的配置中,确保Athens能通过GitLab API获取私有依赖的元数据与归档包
- 在GitLab为Athens创建带
设置Go mod私有仓库映射
在GitLab流水线脚本中添加以下命令,指定私有仓库跳过代理直接拉取:go env -w GOPRIVATE=gitlab.ea.com检查Athens私有仓库支持配置
确认Athens服务已开启私有仓库处理功能:- 检查Athens的存储配置是否允许拉取私有仓库包
- 验证Athens的GitLab身份验证配置是否正确
清理Athens无效缓存
删除Athens对应私有依赖的缓存文件,或重启Athens服务,触发重新拉取依赖
内容的提问来源于stack exchange,提问作者goyalsaransh002
相关产品推荐
相关产品推荐

