dongtang5229 2019-04-13 14:03
浏览 129

如何在詹金斯的私有存储库中使用go模块?

I'm building a go app through Jenkins Pipeline, at first I add all my go depedencies in vendor dir and push to VCS, and then pull all the code when building in Jenkins, this works fine.

Then I want to migrate to go modules, because I have a private lib dependency in Gitlab, so I modify the netrc file in Jenkins server as this page says: git_https, and 'go build' works perfectly in local machine and download all the dependencies as expected, but in Jenkins server has some problem. Here is my Jenkinsfile:

pipeline {
    agent any

    stages {

        stage('build') {
            agent {
                docker { image 'golang:1.12' }
            }

            steps {

                sh "export XDG_CACHE_HOME=/tmp/.cache \
                && go build"
            }
        }

    }
}

As the code shows, I use 'go build' to trigger go module build process, , but still I got this error when building:

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 is my private repository, it seems the config in netrc in Jenkins server didn't work, how can I fix this problem? Thanks for any advice.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
    • ¥30 python代码,帮调试
    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊