gocd / docs.go.cd

GoCD user documentation
https://docs.gocd.org
Apache License 2.0
41 stars 137 forks source link

Include documentation around adding a private Github repo to Go #73

Open anishvenkat opened 7 years ago

anishvenkat commented 7 years ago

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

oxinabox commented 6 years ago

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

ctrabold commented 6 years ago

@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: