Something I encounter every now and then on application deployments. This is common especially on the first time you commit/push your code to your Git repository with CI/CD configured.
Error message looks something like:
./gradlew: Permission denied
The Build stage will fail at this point because gradlew gets a permission denied error and therefore cannot execute the tasks that it is supposed to do.
It is easy to fix this issue with but a few Linux terminal commands.
Why does this happen?
The gradle wrapper build script – gradlew – needs to have its executable bit set on it. In Linux speak it means you are allowing the said script to be able to run as an executable on the system. It may be executable on your local development environment, but when sending code to the repository that executable bit does not get carried over.
In order to get that one bit set on the file, you would need the chmod command.
For this scenario, it is as simple as:
:-$ chmod +x gradlew
Now, this works only if you are also getting the same error when running the gradlew script locally. However, trying to git add and git commit the said file because it was “modified” will also not work. I mean, Git won’t see that change you just made to the file using the above command.
In order to fix this you will need another git command.
:-$ git update-index --chmod=+x gradlew
You are telling git that you are making this file an executable and to register it as a change. Or simply put, it updates or modifies the index of that working tree you are in (the branch) for the changes done to the target file.
Once you have entered the above command, you do not need to add the file to the index. You’ve already done that. Follow through with a commit instead. Then push your changes to the git repository and make the error go away.
Now your pipeline will get past the build stage successfully, then have that application running on Red Hat OpenShift like a boss. (Assuming no other logical code errors and JUnit issues happen, but that’s another topic of course!)
- > Error: uncaught exception: Permission denied to call method XMLHttpRequest.open February 7, 2007
- > Notes On Nagios Configurations October 15, 2013
- > SUSE Kickoff Menu October 31, 2006
- > “PROGRAM_NAME” Is Not Recognized As An Internal Or External Command, Operable Program Or Batch File December 20, 2013
- > Extending Android Device On Desktop May 29, 2020