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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,466,234
Community Members
 
Community Events
176
Community Groups

How to activate pipeline on production (VPS)

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

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

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 Jul 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

Atlassian Community Events