./gradlew: Permission denied

Hello,

I have trouble running ./gradlew check in Gitlab CI. Attempting to run ./gradlew will result in “Permission denied”. I’ve tried the following:

  • Add chmod +x ./gradlew in before_script which results in an “Operation not permitted” error
  • git update-index --chmod=+x gradlew. This updates the flag fine in staged files but doesn’t get committed to HEAD on Windows.

I’ve created a plain demo project to replicate the issue: https://gitlab.com/FrozenGenis/gitlab-ci-permission-test .

Could someone point me in the right direction on how to solve this issue?

Cheers,
Synch

1 Like

Issue has been solved. git update-index --chmod=+x gradlew followed by git commit solved the issue. I kept committing through IntelliJ’s built-in Git feature which seems not able to commit the chmod bit.

1 Like

Thank you for this!

If you had added chmod +x ./gradlew to the build script section, it would have worked. I thought is was an issue where the permissions were changing when the build cloned the repo within the container. I was able to get it to work with the above script line but I wanted to figure out how it was changing.

Your solution saved me a bunch of time since it was something I could fix by updating git locally.

Thanks again,
Anthony