Home > Back-end >  Install CURRENT version of Gradle within CI
Install CURRENT version of Gradle within CI

Time:12-11

Gradle describes their installation in their docs:

https://docs.gradle.org/current/userguide/installation.html

However the docs requires using specific version and there is no easy way to say "get the current version".

I would like to do something like:

export GRADLE_VERSION=`curl https://services.gradle.org/current-version`
curl -sSLO https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip \
    && unzip -q -d /opt/gradle gradle-*.zip \
    && echo "PATH=$PATH:/opt/gradle/gradle-${GRADLE_VERSION}/bin" > ~/.bashrc

Obviously there is no such API service like /current-version. How would you achieve this?

CodePudding user response:

I suggest:

curl -s 'https://services.gradle.org/versions/current' | jq -r '.version'

Output:

7.3.1

or

curl -s 'https://services.gradle.org/versions/current' | jq -r '.downloadUrl'

Output:

https://services.gradle.org/distributions/gradle-7.3.1-bin.zip
  • Related