I'm trying to set up continuous integration with Bamboo. I want to configure a task that ssh's into our stage server, cd's into the proper directory and performs a git pull.
I've been able to set up the ssh task, but doing the git pull has been difficult.
Steps I've taken:
Configured an ssh task to cd into the project directory and run the following script:
#!/bin/bash echo "pulling from master" git pull origin master
The script runs, but the logs show a
Permission denied (publickey).
error after it tries to pull.I switched my remote-url from HTTPS to ssh and created a publickey. Now when I try to do a manual pull it asks for the key's passphrase.
Used
ssh-agent
to cache the passphrase for a session.Realized that this cache only persists until I close my session so I followed the steps from this article (https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git) to start ssh-agent with every new session. Namely I added this script to my
.bashrc
: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
and added this to the .ssh/config file:
Host myStashInstance.org
IdentityFile ~/.ssh/id_rsa
- The article said that I should be prompted to enter the passphrase and the agent would start up but that hasn't happened. I still need manually start ssh-agent.
I would like to know what the next steps would be to getting ssh-agent to start when I start a new session so I can continue figuring out how to finish configuring this job. (Also open to suggestions for other avenues to pursue if I'm completely on the wrong path.)