【发布时间】:2019-09-04 02:05:06
【问题描述】:
我正在通过 Jenkins Pipeline 构建一个 go 应用程序,首先我将所有 go 依赖项添加到供应商目录中并推送到 VCS,然后在 Jenkins 中构建时提取所有代码,这工作正常。
然后我想迁移到 go 模块,因为我在 Gitlab 中有一个私有 lib 依赖项,所以我修改了 Jenkins 服务器中的 netrc 文件,因为这个页面说:git_https,并且“go build”在本地机器上完美运行并按预期下载所有依赖项,但在 Jenkins 服务器中存在一些问题。 这是我的 Jenkins 文件:
pipeline {
agent any
stages {
stage('build') {
agent {
docker { image 'golang:1.12' }
}
steps {
sh "export XDG_CACHE_HOME=/tmp/.cache \
&& go build"
}
}
}
}
正如代码所示,我使用'go build'来触发go模块构建过程,但是在构建时仍然出现此错误:
go get gitlab.com/gbuda/dblib: git ls-remote -q origin in /go/pkg/mod/cache/vcs/a8fb1674af641945219afa3eee63923c22afe0df48bc030a6bf714abb7116332: exit status 128:
fatal: could not read Username for 'https://gitlab.com': terminal prompts disabled
If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.
gitlab.com/gbuda/dblib 是我的私有仓库,Jenkins 服务器中netrc 中的配置似乎不起作用,我该如何解决这个问题?感谢您的建议。
【问题讨论】:
标签: git go jenkins go-modules