docs.go.cd
docs.go.cd copied to clipboard
Include documentation around adding a private Github repo to Go
This is a placeholder for the documentation update to add notes on how to add private Github repositories to Go in the FAQ section.
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 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