I have an appspec.yml file which defines where to deploy the build. (Bitbucket > AWS S3 > AWS Codedeploy > aws EC2 instance)
version: 0.0os:
linux files: - source: /
destination: /var/www/vhosts/<domain>
I want the .php file to be deployed in /var/www/vhosts/<domain>/httpdocs directory?
Can I achieve that using appspec.yml or in bitbucket-pipeline.yml? Is there a better way? Thank you in advance!
my .yml:
image: atlassian/default-image:latest
pipelines:
default:
- step:
name: Install dependencies
image: composer
caches:
- composer
script:
- apt-get update && apt-get install -y unzip
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- composer install --ignore-platform-reqs
- step:
name: Deploy to Staging
deployment: Staging
# trigger: manual # Uncomment to make this a manual step
script:
- apt-get update
- apt-get install -y zip
- apt-get install -y git
- git clone https://username@bitbucket.org/repository/projectgit
- zip -r application1.zip .
- pipe: atlassian/aws-code-deploy:0.5.3
variables:
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
APPLICATION_NAME: $APPLICATION_NAME
S3_BUCKET: $S3_BUCKET
COMMAND: 'upload'
ZIP_FILE: 'application1.zip'
VERSION_LABEL: 'my-app-1.0.0'
- pipe: atlassian/aws-code-deploy:0.5.3
variables:
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
APPLICATION_NAME: $APPLICATION_NAME
DEPLOYMENT_GROUP: $DEPLOYMENT_GROUP
S3_BUCKET: $S3_BUCKET
COMMAND: 'deploy'
WAIT: 'true'
VERSION_LABEL: 'my-app-1.0.0'
IGNORE_APPLICATION_STOP_FAILURES: 'true'
FILE_EXISTS_BEHAVIOR: 'OVERWRITE'
- step:
name: Manual Step Deploy to PROD
image: php:7.2-cli
deployment: Production
trigger: manual
script:
- echo "This step runs once you click the 'Run' button"
PS: not sure why the yml is not indented. I tried copying from notepad++. sublime text but same output.
EDIT: I added this block and SSH keys defined here
- pipe: atlassian/ssh-run:0.2.6
variables:
SSH_USER: 'string'
SERVER: 'string'
COMMAND: './copy.sh'
MODE: 'script'
Contents of my copy.sh file.
echo "copy php file to httpdocs"
cd /var/www/vhosts/<domain>
cp *.php /var/www/vhosts/<domain>/httpdocs
echo "php file is copied.
I get this error after running the Pipeline
<span>INFO: Using default ssh key<br></span><span>INFO: Executing script <a href="https://bitbucket.org/bbtdigital/sample-codedeploy/src/0ca56da3606ffdc2db602f32d97ee888e04faa45/copy.sh" target="_blank" rel="noopener noreferrer">./copy.sh</a> on <host><br></span><span>ssh -i /root/.ssh/pipelines_id -o StrictHostKeyChecking=no -p 22 <user><a href="mailto:bbt_test_delorean@52.64.252.126" target="_blank" rel="noopener nofollow noreferrer">@</a><host> bash -s<br></span><span>ssh: connect to host <host> port 22: Operation timed out<br></span><span>✖ Execution failed.</span><span>INFO: Executing the pipe...<br></span>