docs.go.cd icon indicating copy to clipboard operation
docs.go.cd copied to clipboard

Include documentation around adding a private Github repo to Go

Open anishvenkat opened this issue 8 years ago • 2 comments

This is a placeholder for the documentation update to add notes on how to add private Github repositories to Go in the FAQ section.

anishvenkat avatar Mar 07 '17 06:03 anishvenkat

For anyone finding this issue before it is properly solved with docs, the following threads have some details:

  • https://support.thoughtworks.com/hc/en-us/community/posts/213270746-How-do-I-add-a-Git-Material-for-a-private-GitHub-repository-
  • https://groups.google.com/forum/#!topic/go-cd/a4J_AvLRU8o/discussion

oxinabox avatar Jan 09 '18 01:01 oxinabox

@oxinabox yes, hardcoding the username and password into the material URL works.

Yet I prefer to store sensitive data like this outside the GoCD server. Here's how I've solved it by using .git-credentials:

CONFIG_FOLDER=/var/lib/go-server/config
# also do it on the agents (assuming Docker file structure here)
# CONFIG_FOLDER=/go-agent/config

if [[ -n $GOCD_GITHUB_USERNAME || -n $GOCD_GITHUB_ACCESS_TOKEN ]]; then
  git config --global credential.helper "store --file ${CONFIG_FOLDER}/.git-credentials"
  cat <<EOF > ${CONFIG_FOLDER}/.git-credentials
https://${GOCD_GITHUB_USERNAME}:${GOCD_GITHUB_ACCESS_TOKEN}@github.com
EOF
fi

The .git-credentials file is created either during service startup (e.g. Docker / K8 / OpenShift) with the variables provided or via config management or by hand.

That being said I'd like to hear what the official recommendation in the FAQ for this is.

I think support for secure variables in material URLs would make it much easier for users to configure access for private repos.

Related issues:

  • gocd/gocd#1696
  • gocd/gocd#2511

ctrabold avatar Feb 09 '18 13:02 ctrabold