Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to activate pipeline on production (VPS)

troostmarco July 18, 2022

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

 

 

 

 

 

 

1 answer

1 accepted

1 vote
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 19, 2022

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 : 

  • If the script file is already in the remote VPS server, and you just want to trigger it from your bitbucket pipeline : 
    - step:
    name: 'Deployment to Production'
    deployment: production
    trigger: 'manual'
    script:
    - ssh <USER>@<SERVER './domains/paard.org/deploy.sh'
    - echo "Deploy step finished"

     

  • If the file is in your repository, and you want to execute it in your remote VPS machine without having to copy it :
    - 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

troostmarco July 20, 2022

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:

  • Install npm packages
  • Build javascript and css.
  • Deploy a Wordpress theme from my Bitbucket repository.

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

Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 20, 2022

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

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events