在 Jenkins CI 中随机失败

标签 go docker-compose dockerfile

最近,在 Jenkins 上处理构建时,我在 go get 上遇到了一个问题:尝试构建图像时,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 && \

我会遇到这样的失败:

go get -u github.com/go-sql-driver/mysql cd .; git clone https://github.com/go-sql-driver/mysql /root/go/src/github.com/go-sql-driver/mysql Cloning into '/root/go/src/github.com/go-sql-driver/mysql'... fatal: unable to access 'https://github.com/go-sql-driver/mysql/': Could not resolve host: github.com package github.com/go-sql-driver/mysql: exit status 128

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

非常感谢!

最佳答案

TLDR;只需提交并推送您的 vendor 文件夹即可。

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

关于在 Jenkins CI 中随机失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52765782/

相关文章:

go - 将 go 接口(interface)对象转换/类型转换为具体类型

Dockerfile 镜像构建 : "RUN wget" inside the Dockerfile results in partial file download, 但构建完成且没有错误

docker - 如何找到Docker URL?

高语 : "No common algorithm for key exchange" error

file - Golang读取文件回车

go - 如何获得所有结果而不会出现死锁错误

docker - 通过 docker-compose 将环境变量传递给 YAML

linux - docker 。 docker-compose up后在容器中创建目录并赋予其r/w权限

wordpress - 使用 docker 设置 Wordpress 时的卷挂载

angular - Angular 2应用程序部署在AWS上运行的Docker容器中