如何在詹金斯的私有存储库中使用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.