【问题标题】:Go get randomly failed in Jenkins CIGo 在 Jenkins CI 中随机失败
【发布时间】:2018-10-11 17:24:00
【问题描述】:

最近我在 Jenkins 上处理构建时遇到了一个问题:尝试构建图像时,Go get 命令将随机失败。 例如,我的 Dockerfile 中有几行:

go get -u golang.org/x/lint/golint && \
go get github.com/glaslos/ssdeep && \
go get github.com/mitchellh/mapstructure && \
go get github.com/denisenkom/go-mssqldb && \
go get -u github.com/go-sql-driver/mysql && \
go get github.com/hashicorp/consul/api && \
go get -u github.com/gin-gonic/gin && \
go get -u github.com/gocql/gocql && \
go get github.com/satori/go.uuid && \
go get github.com/golang/protobuf/protoc-gen-go && \

我会遇到这样的失败:

去获取 -u github.com/go-sql-driver/mysql cd .; git 克隆 https://github.com/go-sql-driver/mysql /root/go/src/github.com/go-sql-driver/mysql 克隆到 '/root/go/src/github.com/go-sql-driver/mysql'... 致命:无法 访问“https://github.com/go-sql-driver/mysql/”:无法解析 主机:github.com 包 github.com/go-sql-driver/mysql:退出状态 128

失败的 go 包是随机分发的。 有谁知道避免这个问题?比如不用 go get 就可以得到 go package 的工具等等。

非常感谢!

【问题讨论】:

    标签: go docker-compose dockerfile


    【解决方案1】:

    TLDR;只需提交并推送您的供应商文件夹。

    这可能是由网络问题引起的。我建议您使用供应商解决方案(如 dep 或模块)并将所有依赖项放在供应商文件夹中,这样您就可以确保能够复制构建。甚至 Kubernetes (https://github.com/kubernetes/kubernetes) 在其存储库的供应商文件夹中都有其依赖项。

    【讨论】:

    • 非常感谢!逐步添加供应商
    猜你喜欢
    • 1970-01-01
    • 2014-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-06
    • 2013-04-10
    相关资源
    最近更新 更多