I have a pipeline in butbucket with a runner with docker install on a VPS. When I run the pipeline it fails in the line “git pull origin master”.
I set SSH keys in SSH keys menu on bitbucket I’ve added the file authorized_keys on VPS and it gives this error.
Host bitbucket.org UseKeychain yes IdentityFile ~/.ssh/jga
Error as follows:
Load key "/home/debian/apps/test/1401a1c6-b767-5d08-8df5-6edc1e68ccdb/ssh/id_rsa": invalid format git@bitbucket.org: Permission denied (publickey).
It seems as if I have to configure something inside the docker (runner). I don’t know!
Any ideas?
Hello @jg ,
Welcome to Atlassian Community!
From the error you have shared, it seems like the key you have configured might be wrong formatted or invalid. In order to better understand your current setup, I would like to understand the following :
You are also welcome to take a look in the following documentations that has instructions on using SSH keys in Bitbucket Pipelines, and also the blog post which covers cloning a different bitbucket repo in your pipeline build :
If the above does not work, I kindly ask you to share the bitbucket-pipelines.yml file of your build so I can have a deeper analysis on your current build setup.
Let me know if you have any questions.
Thank you @jg
Kind regards,
Patrik S
Hi Patrick,
Thanks for your help, I’ve done all you told me.
I generated SSH Keys from Repository Settings/SSH Keys and added the the .pub generated in that path (pipeline) to my personal settings/SSH-Keys and the pipeline is running now.
However, the pipeline it doesn’t pull the repo to the VPS’ path. I mapped the volume in the runner and change the WORKING DIRECTORY as well, but I can’t see changes on my VPS’ path. It’s as if changes only are updated inside the runner (docker) but don't reflect in the VPS. This is the result of the pipeline, the runner and the list of files pulled to the docker/runner.
Runner (some values of the vairables has been change for privacy):
docker container run -it -v /home/debian/apps/test:/home/debian/apps/test -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/containers:/var/lib/docker/containers:ro -e ACCOUNT_UUID={SENSITIVE} -e REPOSITORY_UUID={SENSITIVE} -e RUNNER_UUID={SENSITIVE} -e RUNTIME_PREREQUISITES_ENABLED=true -e OAUTH_CLIENT_ID=SENSITIVE -e OAUTH_CLIENT_SECRET=SENSITIVE -e WORKING_DIRECTORY=/home/debian/apps/test --name runner-MY_RUNNER docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner:1
pipeline (this line has been change for privacy: git@bitbucket.org:jg/test.git):
image: rust
pipelines:
branches:
master:
- step:
name: 'Deployment to development'
deployment: Staging
runs-on:
- self.hosted
- linux
- 'dev'
script:
- cd /home/debian/apps/test
- pwd
- git init
- git remote add origin git@bitbucket.org:jg/test.git
- ls -la
- git fetch
- git checkout master
- git pull --rebase
- git config pull.rebase true
- git config pull.ff only
- git pull origin master
- echo "The deployment to dev done";
ls -la (pipeline):
+ ls -la
total 124
drwxr-xr-x 5 root root 4096 Apr 28 15:07 .
drwxr-xr-x 3 root root 4096 Apr 28 15:07 ..
-rw-rw-rw- 1 root root 153 Apr 28 15:07.env
drwxrwxrwx 8 root root 4096 Apr 28 15:07 .git
-rw-rw-rw- 1 root root 8 Apr 28 15:07 .gitignore
drwxr-xr-x 6 root root 4096 Apr 28 15:07 1b56c9ca-2404-53d6-9b1f-003bd120cbef
-rw-rw-rw- 1 root root 44446 Apr 28 15:07 Cargo.lock
-rw-rw-rw- 1 root root 464 Apr 28 15:07 Cargo.toml
-rw-rw-rw- 1 root root 683 Apr 28 15:07 README.md
-rw-rw-rw- 1 root root 1308 Apr 28 15:07 bitbucket-pipelines.yml
drwxrwxrwx 2 root root 4096 Apr 28 15:07 src
However, inside the VPS' path (/home/debian/apps/test) there is nothing inside or pulled.
Thanks
Thank you for providing additional context.
The behaviour you reported is actually expected : when your pipeline triggers a runner to run your build, the runner container will create some temporary folders in the mounted volume (by default /tmp), where it will temporarily save things like artifacts, your yml file and also clone the repository. After the build is done, the runner container will cleanup all the files it has downloaded to run the build, so you have a fresh environment to run the next build steps. So this is why you found the mounted folder to be empty after your build was completed.
Having said that,my understanding is that you are trying to use runners as a way to deploy files to your VPS server, by preserving all the files runner downloaded during the build and I'm afraid this is not currently possible.
My suggestion is this case, if you would like to deploy your files to your VPS server, is to use one of the following pipes :
The above pipes have the option to work authenticating with SSH key, which you have already configured, and will give you the functionally from copying files/folders from within the container to a remote server, in this case your VPS server.
We have also a set of other pipes that can be used to deploy to specific services, such as aws. You can take a look at deployment pipes in the link below :
Hope that helps to clarify your questions. Let me know in case you have any doubt.
Thank you, @jg .
Thanks for your anwser.
Ok I understand now. All changes will be on the container (runner).
I run the scp-deploy and works. Then, I don't need the runner, do I?.
What I don't get Is how I get changes from the runner, If I use artifacts to be used in the next step, the path will be also on dist/, inside the container.
If I run the runner on the VPS, whats is it for?, if I can't get changes on the VPS using the runner (container in my infrastructure with a volume). Sorry, I read some articles about the runner, but I don't get it.
If the main aim is to deploy and update changes from local to the remote machine, how can I use the runner to deploy my changes without using scp/sftp or rsync?.
It looks like you're new here. Sign in or register to get started.