Reputation: 895
I cant get Jenkins to connect to my git repository. I suspect my problem is in the location of my keys. Where should I place the keys ? What I have read is that it should be placed in Jenkins home directory. Is that the directory that Jenkins is running as? /home/tomcat or what jenkins say is its home directory from the configure system /opt/bitnami/apps/jenkins/jenkins_home? Is it nessary to also have a config file in the same directory as the keys?
Upvotes: 1
Views: 2472
Reputation: 31
Zach, You may have solved this long ago, but just in case anyone else is looking for the answer, here is what worked for me. There isn't anything fancy here--if you can use git as user tomcat and interact with your git repo that is all there is to it. Don't do anything more in jenkins build jobs other than supplying a project repo location (no key setup or credentials, etc.) We will let git and ssh outside of Jenkins do all the work.
I use the bitnami jenkins AMI as well and indeed it runs Jenkins as a war app in Tomcat--so it runs as Tomcat.
PATH="/opt/bitnami/git/bin:$PATH"
'git --version' should work now as tomcat user, so do the typical git first time setup
now the ssh setup
Host bitbucket.org
IdentityFile ~/.ssh/id_rsa
Final Check
(Optional)
I did the following to help verify my key setup and fingerprint, but I don't think it was essential.
SSH_ENV=$HOME/.ssh/environment
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add
}
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi
Upvotes: 3