Forums

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

changing file permissions in a test fails in bitbucket pipeline

stefanofornari
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 13, 2023

I have a test to make sure the application provides a proper error if it can not access a file. To do so, the test changes the file permission, that it runs the application and checks the error.

Something like:

public void permissions() {
  String file = prepareFiles(); // let's say this creates a file /tmp/myfiles/filetocheck

  Path path = Paths.get(file).getParent();
  Files.setPosixFilePermissions(path, PosixFilePermissions.fromString("---------"));

  MyApp.main();

  thenLogContains("no access to " + file + ": java.nio.file.AccessDeniedException")
}

It works locally, but when it runs in the BitBucket pipeline, it fails because permissions have not been changed. Has anybody ran into the same problem? Any solution?

1 answer

1 accepted

0 votes
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 14, 2023

Hello @stefanofornari and welcome to the Community!

Have you tried testing it locally inside a docker container ? I ask this because bitbucket pipelines run inside a docker container, so testing it locally with docker closely reproduces the pipeline environment and it can help identify if the issue is with the pipelines itself or with the code/image you are using.

If you haven't already, I would suggest following the instructions in the article below to debug it locally using the same image you are using in pipelines: 

Let us know in case you have any questions.

Thank you, @stefanofornari !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events