Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In order to add a new server we first need to add the public bitbucket SSH key to the server that you can get from the SSH Keys page of the Repository Settings in Bitbucket. From here you can also add the IP address of the server by typing it under Known Hosts and the hitting fetch. After you retrieve the fingerprint, you can then add the host by clicking the Add Host button.

...

Once the new server has been added to the SSH keys page then you can add the server to the correct pipeline. Go to the source page for the code. Switch to the production branch. Then click on the bitbucket-pipelines.yml file. From there you can click on Edit to edit the file for just that branch.

You can add this at the end of the file. Replace project_name with the project’s name. Replace 0.0.0.0 with the server’s IP addres and replace /path/to/project with the absolute file path to the project.

project_name:
- step:
name: SSH to project root on server and change ownership
script:
- ssh ubuntu@0.0.0.0 ‘sudo chown -R ubuntu:ubuntu /path/to/project'
- step:
name: Deploy
script:
- pipe: atlassian/rsync-deploy:0.7.1
variables:
USER: "ubuntu"
SERVER: "0.0.0.0"
REMOTE_PATH: ‘/path/to/project'
LOCAL_PATH: '*'
DELETE_FLAG: 'false’
- step:
name: SSH to project root on server and change ownership back and change file permissions
script:
- ssh ubuntu@0.0.0.0 'sudo find /path/to/project -type f -exec chmod 664 {} \;'
- ssh ubuntu@0.0.0.0 'sudo find /path/to/project -type d -exec chmod 775 {} \;'
- ssh ubuntu@0.0.0.0 'sudo chown -R apache:apache /path/to/project'

Then commit the file.

To Run a Pipeline/Deploy:

Click Run Pipeline on the Repository’s Pipeline page in Bitbucket.

...