Tonight I went in to work to finish up connecting our supply chain supplier web service to a new Salesforce backend. After writing up some tests, I thought it’d be good to wire this project up in our Bamboo daily builder server. I figured, it’s such a simple app, and I’m cloning an existing build plan, should take 2 minutes tops. An hour and a half later I got it working after fighting multiple battles!

Permission Denied Battle

When I ran the bamboo plan it failed nearly instantaneously. Turns out the gradlew script of the project didn’t have execute rights. I suppose that makes sense… file was auto-created on windows by gradle, committed to linux source control server, checked out onto a linux build server… nowhere did I or any process explicitly say the file should have execute permissions, but I don’t claim to be a linux guru either.

So I went to google and I came across this helpful stackoverflow post that pointed out I needed to chmod +x gradlew OK, sounds reasonable.

Failed Attempt 1 – Change File Permission on Windows

I first thought I’d just enable the “execute” permission on the file, but that didn’t readily show itself apparent how on my windows machine (you may laugh now).

Failed Attempt 2 – Change File Permission on Source Repository

I then thought, well, let’s just chmod the file in source control. Doh… git stores everything as hashes and I wasn’t about to traverse that table of file directories… it may be possible to have solved my problem within git but I didn’t take the time to find out, I needed a quick solution now so I could get home (I’m working a Saturday afternoon and been there 6 hours!).

Third Time’s A Charm – Change File Permission on Build Server

I then remembered that Bamboo will let you wire up an inline script task as a step in your job. Terrific, so I added a new script task into my default job, between the step that “checks the code out from git” and the step that “launches the ant build”. The inline script simply issued two commands:

  chmod +x gradlew
  chmod +x gradlew.bat

Voila! Now my build ran, tests successful, green light baby and I’m heading home =)

I’m not claiming this is the “best” solution, and I’m certainly open to other ideas. But what I do like about this solution is that from now on it doesn’t matter if the gradlew wrapper has the execute attribute or not when it’s put into source control, the bamboo build plan will ensure it, and hopefully no other developers on the team will have to run into this problem, especially since we typically clone existing plans rather than starting fresh each time.