Hi!
I have created a shell script called deploy.sh on my VPS. This script works fine when typed in the terminal, but doesn't fire when being called from my pipeline.
bitbucket-pipeline.yml
image: atlassian/default-image:3
pipelines:
default:
- parallel:
- step:
name: 'Build and Test'
script:
- echo "Your build and test goes here..."
- step:
name: 'Deployment to Production'
deployment: production
trigger: 'manual'
script:
- cd ./domains/paard.org && sh deploy.sh | ssh <USER>@<HOST>
- echo "Deploy step finished"
deploy.sh
echo "Deploy script started"
cd /home/pimpzilla/domains/paard.org
sh pull.sh
echo "Deploy script finished execution"
pull.sh
#/home/pimpzilla/domains/paard.org
git pull origin master
npm install
npm run production
echo 'Deploy finished'
? Any ideas why the pipeline doesn't fire deploy.sh ?
kind regards, Marco
Hello @troostmarco ,
Thank you for reaching out to Atlassian Support.
From my understanding, you would like to SSH into your VPS server from within your pipeline build, and run the deploy.sh on the VPS machine.
If that is the case, I think the syntax you have used in your yml file is slightly wrong. Let me share some examples of the commands you should use how to achieve that :
- step:
name: 'Deployment to Production'
deployment: production
trigger: 'manual'
script:
- ssh <USER>@<SERVER './domains/paard.org/deploy.sh'
- echo "Deploy step finished"
- step:
name: 'Deployment to Production'
deployment: production
trigger: 'manual'
script:
- ssh <USER>@<SERVER> 'bash -s' < ./path_to_repo_script/deploy.sh
- echo "Deploy step finished"
I would also suggest taking a look at the ssh-run pipe, which essentially implements the functionality you are looking for, and you would just need to provide some variables for its configuration :
Hope that helps! Let me know n case you have any questions.
Thank you, @troostmarco .
Kind regards,
Patrik S
Hi Patrick,
Thanks for your comprehensive answer. After reading some more on pipelines, i've decided to go for another approach though.
The shell task on my VPS isn't really necessary.
All of the deployment-logic can exist in the pipeline itself. This seems better to me, given the fact that whenever a step fails, the pipeline won't deploy.
What i basically want to achieve:
This is the code i know use & it works like a charm.
- step:
name: 'Deployment to Production'
deployment: production
script:
- pipe: atlassian/scp-deploy:1.2.1
variables:
USER: <USER>
SERVER: <SERVER>
REMOTE_PATH: '/home/pimpzilla/domains/paard.org/dist'
LOCAL_PATH: 'dist/*'
DEBUG: 'true'
EXTRA_ARGS: ["-P", "4567"]
- pipe: atlassian/rsync-deploy:0.7.1
variables:
USER: <USER>
SERVER: <SERVER>
REMOTE_PATH: '/home/pimpzilla/domains/paard.org/wp-content/themes/'
LOCAL_PATH: 'wp-content/themes/twentytwentyone-child'
DEBUG: 'true'
SSH_PORT: '4567'
kind regards, Marco
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @troostmarco ,
Happy to hear you were able to get it working, and thanks for sharing your solution!
Feel free to reach out to the community in case you need further assistance.
Thank you, @troostmarco !
Kind regards,
Patrik S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.