简体   繁体   中英

build go project in Jenkins with dependencies in private repository

I'm trying to set up automated build for go projects. Most people just use github dependencies which don't need credentials. We have some internal dependencies however available on our private git central server. Credentials are needed however to have go access these.

A possible workaround would be to configure a global git variable inside our build machines / build dockers; something like:

git config --global url."https://user:password@private.git.server/".insteadOf "https://private.git.server/"

however this doesn't seem to be the best solution to me, since the password would be stored in a human-readable text file.

I think the git-credentials plugin should be able to help me out; could I maybe export GIT_TERMINAL_PROMPT=1 and let the git-credentials plugin fill in for me?

How could I make sure go get or go install gets access to our private repository in a secure way?

I use a workaround with GITHUB_TOKEN to solve this.

  1. Generate GITHUB_TOKEN here https://github.com/settings/tokens
  2. export GITHUB_TOKEN=xxx
  3. git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/mycompany".insteadOf "https://github.com/mycompany"

This way you don't expose the password and can revoke token at any time.

Note: Go uses http when downloading dependencies, not ssh .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM