Using gradle as build tool

I’m using circleci/python:3.7 and I want to add Gradle to this image.
I added the next command:
description: “Install gradle”
- run:
command: |
wget -O ~/
sudo apt-get install unzip
sudo mkdir /opt/gradle
sudo unzip -d /opt/gradle ~/
sudo touch /etc/profile.d/
sudo echo “export GRADLE_HOME=/opt/gradle/gradle-5.4.1” >> /etc/profile.d/
sudo echo “PATH={GRADLE_HOME}/bin:{PATH}” >> /etc/profile.d/
sudo chmod +x /etc/profile.d/
sudo source /etc/profile.d/
gradle -v

But I have a permission problem to install.
Does anyone have any idea how to install it?

Hi Uri, welcome! There are a number of commands there, can you share the error you are getting so we can help figure out which one is having the permissions problem?

The error is: /bin/bash: line 5: /etc/profile.d/ Permission denied

It looks like it’s the sudo touch /etc/profile.d/ command then, if I’m counting lines correctly.

Which is strange, since you are using sudo. Can you check if the /etc/profile.d/ directory exists first?

Yes I will check it

The problematic command is:
sudo echo “export GRADLE_HOME=/opt/gradle/gradle-5.4.1” >> /etc/profile.d/

Ah, I’m run into that before. You will want to | sudo tee if I recall, instead of the >> since that doesn’t have permission.

Working !!!
Thanks you !

1 Like