This tutorial will show how to run Gradle Enterprise on the Google Cloud Platform.

You can complete this tutorial in:

  • 10 minutes (read the tutorial)

  • 30 minutes (read the tutorial and perform the installation)

Gradle Enterprise can be installed on most modern Linux servers. The majority of this tutorial is a quick start guide to creating and minimally configuring an instance in GCP for a Gradle Enterprise installation. If you already have GCP expertise and are able to provision an instance, you may wish to skip straight to the Gradle Enterprise installation instructions.

If you are trialing Gradle Enterprise, you may prefer a free 30-day hosted trial that requires no installation or server.

Prerequisites

1. A Google Cloud Platform account

You can create a free account if you do not already have one.

2. A Gradle Enterprise license

Fill out this form to receive a free 30 day trial license. If you have purchased Gradle Enterprise, you will already have a license file.

3. The gcloud command line tool.

You will be using the gcloud command line tool to provision and configure our server. To install on your local machine, there are instructions in the Google Cloud documentation.

4. Hostname (optional)

Google Cloud Platform machines are provisioned with an external IP address but no hostname. If you want to access Gradle Enterprise by a host name of your choosing (e.g. gradle.mycompany.com), you will need the ability to create the necessary DNS record to route this name to the instance IP address.

You are able to easily update this later. You can start with the raw IP address, and later reconfigure to use a custom hostname if desired.

5. SSL Certificate (optional)

Your Gradle Enterprise instance will be accessible via the public Internet. By default, all communication with Gradle Enterprise is encrypted over HTTPS, either via self-signed certificate or a certificate issued to you by a trusted certificate authority. Once Gradle Enterprise is installed, you may switch off HTTPS via the Gradle Enterprise Admin Console if you prefer.

Using a self-signed certificate will require some extra configuration for the users of your Gradle Enterprise installation, but will also result in traffic being encrypted.

Creating a GCP Server

In this section you will create a Google Cloud Platform instance to run Gradle Enterprise.

1. Log in to GCP

First, you need to log in to GCP by entering the command:

$ gcloud auth login

This will open a browser window and let you select the registered user to use. Once this is done, the following output will be displayed in the terminal window.

You are now logged in as [user@company.com].

2. Create a project and enable billing

Machines on the Google Cloud Platform are organized into projects which have to have a globally unique ID between 6 and 30 characters in length (lowercase letters, digits or hyphens and starting with a letter).

If you already have a project you want to use, you can skip creating a new one and just issue the command gcloud config set project «project-name».

Once you’ve decided on your «unique-project-id», you can issue the command:

$ gcloud projects create «unique-project-id»

After your project is created, you will need to enable billing via the UI by visiting this page, clicking “Select” to choose your freshly created Project, and then clicking “Link a billing account”.

You can then set this as the default project for gcloud by entering:

$ gcloud config set project «unique-project-id»

3. Create a virtual machine

Looking at the requirements in the Gradle Enterprise Admin Manual, let’s create an instance with 250GB of storage, 4 CPUs and 8GB of RAM.

If you do not have a preferred operating system, gcloud will use debian-9 as a base operating system. The list of supported operating systems supported by Gradle Enterprise can be found here.

For this tutorial, let’s name the instance gradle-enterprise and define our settings by entering the following command in the terminal:

$ gcloud compute instances create gradle-enterprise --custom-cpu=4 --custom-memory=8GB --boot-disk-size=250GB
If you have a preferred supported operating system, you can pass it as a parameter to the create command as described here. A list of public base images can be found here.

You will be asked if you want to enable the “compute.googleapis.com” for your project. Choose “Yes” to continue.

Then you will be asked to select a geographical zone to launch the instance in

For the following instance:
 - [gradle-enterprise]
choose a zone:
 [1] asia-east1-a
 [2] asia-east1-b
 [3] asia-east1-c
 [4] asia-northeast1-a
 [5] asia-northeast1-b
 [6] asia-northeast1-c
 [7] asia-south1-a
 [8] asia-south1-b
 [9] asia-south1-c
 [10] asia-southeast1-a
 [11] asia-southeast1-b
 [12] australia-southeast1-a
 [13] australia-southeast1-b
 [14] australia-southeast1-c
 [15] europe-west1-b

...snip...

 [41] us-east4-b
 [42] us-east4-c
 [43] us-west1-a
 [44] us-west1-b
 [45] us-west1-c
Please enter your numeric choice:

You should generally pick the zone closest to you geographically to ensure the best performance, by entering the number next to the zone of choice.

The instance will then be created and in the output, you can see the “EXTERNAL_IP” of the instance 35.189.200.63.

Created [https://www.googleapis.com/compute/v1/projects/gradle-enterprise-tutorial/zones/europe-west1-b/instances/gradle-enterprise].
NAME               ZONE            MACHINE_TYPE               PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP    STATUS
gradle-enterprise  europe-west1-b  custom (4 vCPU, 8.00 GiB)               10.132.0.2   35.189.200.63  RUNNING

4. Set up firewall rules

On the Google Compute Platform, firewall rules are set at project level. There are some ports you will need to expose to access Gradle Enterprise. These are:

  • Port 80 for HTTP

  • Port 443 for HTTPS

  • Port 8800 for the Gradle Enterprise admin console

This can be done via the following three commands:

$ gcloud compute firewall-rules create ge-http --allow tcp:80 --description="GE HTTP"
$ gcloud compute firewall-rules create ge-https --allow tcp:443 --description="GE HTTPS"
$ gcloud compute firewall-rules create ge-console --allow tcp:8800 --description="GE Admin Console"

You can check these have been set correctly by the command:

$ gcloud compute firewall-rules list

NAME                    NETWORK  DIRECTION  PRIORITY  ALLOW                         DENY
default-allow-icmp      default  INGRESS    65534     icmp
default-allow-internal  default  INGRESS    65534     tcp:0-65535,udp:0-65535,icmp
default-allow-rdp       default  INGRESS    65534     tcp:3389
default-allow-ssh       default  INGRESS    65534     tcp:22
ge-http                 default  INGRESS    1000      tcp:80
ge-https                default  INGRESS    1000      tcp:443
ge-console              default  INGRESS    1000      tcp:8800

5. Configure the hostname

If you intend to use a custom hostname to access your Gradle Enterprise instance, you now need to add the appropriate DNS records.

Add an A record for your hostname that points to the “External IP” address of your instance which you saw at the end of step 3 of this tutorial.

gradle-enterprise.company.com A 35.189.200.63

Alternatively, you can just use the “External IP” address in the following steps.

Whichever you choose, for the rest of the tutorial, this will be referred to as the «instance-address».

Installing Gradle Enterprise

In this section you will install Gradle Enterprise on your newly created instance.

1. Install the admin console

SSH into your instance with the following command:

$ gcloud compute ssh gradle-enterprise

This will ask you for a passphrase (which you will need to remember for next time you want to access the instance) and generate an SSH key. It will then ask you for the passphrase again, and if successful will give you command line access to the machine.

Once you’re on the machine, start the installation by issuing the command:

$ curl -sSL https://get.replicated.com/docker/gradleenterprise/stable | sudo bash

The installer will ask if you require a proxy to access the internet. Choose “No” to continue.

2. Configure your hostname

Once that has finished installing, open a web browser and navigate to https://«instance-address»:8800 to access the admin console (you will need to accept the warning in your browser due to there not being a valid SSL certificate).

install ssl 2017.7

Enter «instance-address» into the hostname field.

If you have a trusted SSL certificate for your hostname, you can upload it here. Otherwise, click “Use Self-Signed Cert”.

3. Upload your license

Select “Choose license” and specify your license file.

install license 2017.7

4. Secure the admin console

Choose a method for securing the admin console “Continue”.

install password 2017.7

5. Finish installation

The system will then perform some pre-flight checks, after which you can select “Continue”, and then select “Dashboard” from the navigation menu at the top of the page.

The latest version of Gradle Enterprise will begin downloading and will start automatically.

update started 2017.7

Once the dashboard shows “Started” in the left-hand panel, you can access Gradle Enterprise by either clicking “Open”, or by navigating to https://«instance-address».

Using Gradle Enterprise

Please consult the Getting Started with Gradle Enterprise guide for how to configure your Gradle builds to leverage your new Gradle Enterprise installation.

Stopping your instance

When you wish to shut down your instance, you simply need to enter the command

$ gcloud compute instances delete gradle-enterprise

This will inform you that the instance and attached storage will be destroyed, and ask if you are sure. Choose “Yes” to continue.

If you also want to remove the project you created in step 2 then you can run the command

$ gcloud projects delete «unique-project-id»

And again, choose “Yes” to continue.

Further reading