Jenkins, Cygwin, Windows 7, and permissions

Cygwin is a godsend for controlling your workflow and putting together the sort of tools that keep devops humming along. And Jenkins is a great freeform build tool for managing pretty much any software CI/build process.

But Cygwin and Windows permissions don’t always play nicely, especially when you add intermediary processes like Jenkins to the mix. My build scripts were copying various folders into the Jenkins workspace, among other things. However, the files and directories ended up having all sorts of nasty permissions issues. Certain users (like the ASP.NET app pool identity) could not read files, and overall things looked pretty weird.

So, Icacls to the rescue! Right?

icacls the-dir /reset /T /C /Q
... <snip 5000 lines of Access Denied errors>

I was getting “Access Denied” errors on every file in the directory, even when I made sure to run cmd.exe as Administrator. Icacls was not working to take ownership either, so I tried Takeown. It worked to take ownership where Icacls did not.

takeown /F the-dir /R
icacls the-dir /reset /T /C /Q

All is well now. I hope this might help someone with the same issues.