Jenkins: Permission denied to a 777 file

Adam Matan picture Adam Matan · Jun 4, 2012 · Viewed 10.1k times · Source

I have created a Jenkins build to compile and distribute some modules. The output of the build commands (e.g., make or ant) is redirected to a file named build.log.

The funny thing is that redirecting echo into the very same file, using tee, fails:

tee: ../../build.log: Permission denied

The file exists and has 777 permissions (checked with ls -ltrh ../..). Any ideas what's wrong with this write?

Answer

Edwin Buck picture Edwin Buck · Jun 4, 2012

Permissions on a file are important, but so are permissions on the super directories of that file.

If you do not have read and execute permissions on the directories you are traversing through, then you cannot follow the relative path to the file. If you lack read permissions on the directory "build.log" resides in, you cannot list the files in that directory. Read, Write, and Execute permissions do matter for directories, and they roughly map to:

  • Read = allows Listing of files
  • Write = allows Creating / Deleting / Modifying files
  • Execute = allows changing directory to this directory