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

Pipelines "scp-deploy" puts everything in "build" dir on the remote server

Duncan MacKenzie May 3, 2019

We're trying to deploy a simple PHP project with no build process, all we need to do in the pipeline is `scp` copy the files up to a remote server.

Here's our pipeline config:

image: php:5.6.30

pipelines:
branches:
master:
- step:
script:
- pipe: atlassian/scp-deploy:0.3.3
variables:
USER: '<username>'
SERVER: '<ip addr>'
REMOTE_PATH: '/var/www/api/v1/'
LOCAL_PATH: $BITBUCKET_CLONE_DIR

We want it to put the files from the repo into /var/www/api/v1 on the remote machine, but instead it creates a `build` dir that looks like it has 777 permissions, and puts them in there. (/var/www/api/v1/build/<files>)

Where does this build dir come from? Can we disable that? Or do we have the wrong `LOCAL_PATH` value?

 

1 answer

1 accepted

1 vote
Answer accepted
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 6, 2019

Hi Duncan,

Thank you for your question.

In your case use:


LOCAL_PATH: '${BITBUCKET_CLONE_DIR}/*'

To deploy only files from your directory to the remote you can provide '/local/path/build/*' with trailing asterisk symbol (*) as a LOCAL_PATH variable.

Duncan MacKenzie May 6, 2019

Thanks! That looks like it copies the correct files, but they all have 777 permissions on the remote machine. Is there something else I need to do to specify the target permissions?

Like # people like this
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 8, 2019

Pipe "SCP deploy" preserves modification times, access times, and modes from the original file. Try to check permissions on your local at first.

But additionally, you can add to your config "SSH run" pipe with a command that modifies targets permissions on the remote:

- pipe: atlassian/ssh-run:0.1.3
variables:
SSH_USER: $USER
SERVER: $SERVER
COMMAND: 'chmod 755 <your_target_file>'

More information about pipe "SSH run" you can find in the Bitbucket Pipelines SSH run repository.

Atlassian created pipes are kept in the Bitbucket Pipelines pipes project.

Like # people like this
Ed Bateman November 7, 2019

It would be good to have this on the pipeline information screen (on the screen when adding a new pipeline)

Like mkarthauser likes this
f777 February 18, 2021

The problem is the trailing asterisk symbol (*) in the LOCAL_PATH variable leads to the fact that hidden files will not be copied (any files starting with "." - .htaccess, .env, etc). It is a general Linux behavior, but it would be nice to have some way to copy the hidden files and don't have a "build" directory on the server.

f777 February 18, 2021

I found a solution: just use atlassian/rsync-deploy  and a slash at the end of LOCAL_PATH. Then hidden files will be copied and "build" dir will not be created.

script:
- pipe: atlassian/rsync-deploy:0.4.4
variables:
USER: $USER
SERVER: $SERVER
REMOTE_PATH: '~/projects/${BITBUCKET_REPO_SLUG}/'
LOCAL_PATH: '${BITBUCKET_CLONE_DIR}/'
Like schind likes this
Mukesh Rawat January 26, 2022

hi, 

is there any way I can use more than two remote path like I want to move two folder build and config from my bitbucket to two different location on my server.

Is there any way we can do this without rewriting the steps.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events