Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Permissions problem when deploying via a pipeline

jakemcmurchie
April 15, 2026

When I deploy files to a cPanel account, the permissions given to files is 666 and directories 777.  On my local machine, they are 644 and 755 respectively.

I found this:

https://support.atlassian.com/bitbucket-cloud/kb/manage-file-permissions-in-bitbucket-cloud-pipelines/

So I've updated my bitbucket-pipelines.yml to this:

pipelines:
branches:
"*":
- step:
name: "Build and Set Permissions"
caches:
- docker
services:
- docker
script:
- find . -type d -exec chmod 755 {} \;
- find . -type f -exec chmod 644 {} \;
- DOCKER_BUILDKIT=1 docker image build --no-cache --progress=plain .
main:
- step:
name: "Deploy to live"
script:
- pipe: atlassian/sftp-deploy:0.10.0
variables:
USER: $SFTP_USERNAME_LIVE
SERVER: $SFTP_LOCATION_LIVE
REMOTE_PATH: "public_html/"
LOCAL_PATH: "./"

... but it's still creating files on the server with 666 / 777 permissions.

Any help appreciated!  Thanks in advance. 

1 answer

0 votes
Curtis
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 15, 2026

You are modifying the files in your "Build and Set Permissions" step. But the "Deploy to live" step does not see those modified files. It has its own new set of cloned files.

You need to set the modified files as an artifact from the "Build" step so they are available to the "Deploy" step. You likely also want to disable the "Deploy" step from cloning the repository, since you want the files from the prior step shared via the artifact.

pipelines:
branches:
"*":
- step:
name: "Build and Set Permissions"
script:
- find . -type d -exec chmod 755 {} \;
- find . -type f -exec chmod 644 {} \;
artifacts:
- files/**
main:
- step:
name: "Deploy to live"
clone:
enabled: false
script:
- pipe: atlassian/sftp-deploy:0.10.0
variables:
USER: $SFTP_USERNAME_LIVE
SERVER: $SFTP_LOCATION_LIVE
REMOTE_PATH: "public_html/"
LOCAL_PATH: "./"

 You will have to change the artifacts to get the files you want to carry over to your Deploy step. I also removed all the Docker references to simplify the changes made.

Now, this will have the files with the desired permissions when running the SFTP command. The server though could have is own umask settings and be modifying the permissions once uploaded. If that is the case, then none of this matters in Bitbucket Pipelines and the fix needs to be done on the hosting server.

jakemcmurchie
April 16, 2026

Thank you!  That works perfectly.

This page says : "Bitbucket Pipelines sets the umask to 0022, causing cloned files to have 666 permissions".

Do you know why?  The web host for this repository wouldn't serve the files because it deems 666 to be a security risk (which is quite common, I hear).

Thanks again.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events