Deployment Process
We have moved all deployment process functionality into Bitbucket Pipelines:
Production and Staging branches now have a bitbucket-pipelines.yml file that contains a different pipeline for each server environment.
Steps to add a new server:
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.
Select Production, then select the Server that you want to deploy to and click run. It should take about an hour to deploy everything. Multiple pipelines can be run at the same time.
After the pipeline has completed successfully you need to visit the following URLs of the server you deployed to:
{server URL}/auditprotocol/test.php
{server URL}/itam-shared/ITAM-Upgrade/DBUpgradeUrl.php
Future Iterations of our deployment process will include:
Linking with LaunchDarkly to Trigger all deployments with one touch
Converting our test.php and DBUpgradeUrl.php files to be able to be triggered via command line PHP and integrated into the process
Moving only changed files onto server instead of all files in repository