Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Jenkins中构建go项目,在私有存储库中具有依赖项_Go_Jenkins_Credentials - Fatal编程技术网

在Jenkins中构建go项目,在私有存储库中具有依赖项

在Jenkins中构建go项目,在私有存储库中具有依赖项,go,jenkins,credentials,Go,Jenkins,Credentials,我正在尝试为go项目设置自动构建。大多数人只使用不需要凭据的github依赖项。我们有一些内部依赖项,但是可以在我们的私有git中央服务器上使用。但是,需要凭据才能访问这些 一个可能的解决方法是在我们的构建机器/构建dockers中配置一个全局git变量;比如: git config --global url."https://user:password@private.git.server/".insteadOf "https://private.git.server/" 然而,这似乎不是我

我正在尝试为
go
项目设置自动构建。大多数人只使用不需要凭据的github依赖项。我们有一些内部依赖项,但是可以在我们的私有git中央服务器上使用。但是,需要凭据才能访问这些

一个可能的解决方法是在我们的构建机器/构建dockers中配置一个全局git变量;比如:

git config --global url."https://user:password@private.git.server/".insteadOf "https://private.git.server/"
然而,这似乎不是我的最佳解决方案,因为密码将存储在一个人类可读的文本文件中

我认为
git-credentials
插件应该能够帮助我;我可以导出
GIT\u TERMINAL\u PROMPT=1
并让
GIT凭证
插件替我填写吗


如何确保
go-get
go-install
以安全的方式访问我们的私有存储库?

我使用GITHUB\u令牌的解决方法来解决这个问题

  • 在此处生成
    GITHUB\u令牌
  • export GITHUB\u TOKEN=xxx
  • git-config--global-url.“https://${GITHUB\u-TOKEN}:x-oauth-basic@github.com/“我的公司”取代“我的公司”https://github.com/mycompany“
  • 这样,您就不会公开密码,并且可以随时撤销令牌


    注意:Go在下载依赖项时使用
    http
    ,而不是
    ssh

    是;我不公开密码;但是我公开了具有相同安全风险的令牌,对吗?是和否,令牌具有安全风险,但您可以定义其访问级别。此外,您还可以存储它的加密版本。