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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Copy a file to a specific directory after deployment?

Edited

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

INFO: Executing the pipe...
INFO: Using default ssh key
INFO: Executing script ./copy.sh on <host>
ssh -i /root/.ssh/pipelines_id -o StrictHostKeyChecking=no -p 22 <user>@<host> bash -s
ssh: connect to host <host> port 22: Operation timed out
✖ Execution failed.

 

1 answer

1 accepted

0 votes
Answer accepted

For meantime, I deployed all files in httpdocs directory. I edited my appspec.yml file.

version0.0

oslinux 

files: - source/

destination/var/www/vhosts/<domain>/httpdocs/

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

694 views 17 19
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you