0

I currently have a bitbucket repository with a pipeline to Digital Occean. However, Digital Ocean does not pull from the repo successfully.

So far I have:

  • A bitbucket pipeline with pointing to the Digital Ocean droplet
  • A bitbucket SSH public key which has been added to the Digital Ocean droplet
  • A deploy.sh file on Digital Ocean which kicks off the deployment process and is referenced by the pipeline on bitbucket
  • A pull.sh file on Digital Ocean which retrieves the latest build from bitbucket and starts the application

What I'm finding is that the pipeline on the bitbucket side fails. And, if I attempt to run pull.sh manually, I am prompted for the password to the bitbucket repo.

Have I set up SSH incorrectly?

enter image description here

Note that I can find no syntax errors with the pipeline.

On Bitbucket

Bitbucket Pipeline

Variables <user> and <host> are correctly configured.

image: atlassian/default-image:latest

pipelines:
  default:
    - step:
        deployment: staging
        script:
          - cat ./deploy.sh | ssh <user>@<host>
          - echo "Deploy step finished" 

Bitbucket SSH Key

  • Private Key is configured
  • Public Key is configured
  • Known host has been added and a Host Address (the Digital Ocean Ubuntu droplet IPv4 address) and has a fingerprint

On Digital Ocean

Authorized Key

  • Public key provided by Digital Ocean has been added to /root/.ssh/authorized_keys

Deploy.sh

Is located in /

echo "Deploy Script Started"
cd
sh pull.sh
echo "Deploy script finished execution"

Pull.sh

Is located in '/'

cd eg-api
git pull origin master
echo 'Repo: Local Copy Updated'
cd refgator-api
python3 refgator-api.py
TheMightyLlama
  • 1,243
  • 1
  • 19
  • 51

1 Answers1

1

I figured out the problem from this answer.

I had originally cloned the repo with https which meant that I would always be asked for a password.

Changing the git config files to use the SSH url allowed my script to do a git pull without needing a password. Something similar to the below.

[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = git@bitbucket.org:TheMightyLlama/therepo.git
TheMightyLlama
  • 1,243
  • 1
  • 19
  • 51