1

I have setup bitbucket pipeline to push updates on the staging server when a commit is made. I am using git ftp for that.

On the next step I need to run various command on the deployment (staging) server in order to run the app properly after the push.

For example:

  1. composer install

  2. php artisan db:seed

  3. php artisan migrate

.. and so on.

Sisir
  • 2,668
  • 6
  • 47
  • 82

2 Answers2

4

You can you try to add a step to run a shell script by ssh.

$ ssh user@host.example "ls -la"

in your case,

$ ssh user@host.example "php artisan db:seed"

You can find further ways to run here: How to use SSH to run a shell script on a remote machine?

And regarding composer step, you can add in your receipe:

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

composer install --no-interaction --no-progress --prefer-dist

2

If your staging server is on a Cloud Service like AWS then you could use AWS CodeDeploy via a python-script using boto for the same. Or in case you use something else, whatever the equivalent that would be. Deployment guides at https://confluence.atlassian.com/bitbucket/build-test-and-deploy-with-pipelines-792496469.html has more relevant details.

In case your server is an on-premise server (and UNIX based) you could use a ssh key-pair to execute commands on the server like:

ssh -i xyz.pem user1@server1 'command -args'
ssh -i xyz.pem user1@server1 'command -args'
Animesh
  • 227
  • 2
  • 9
  • Staging server is not in AWS its on a VPS. ssh command execution seems to be right way to go. – Sisir Oct 14 '17 at 14:07