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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.