How to Install Jenkins on Google Cloud Platform

If you are looking to configure continuous integration over your deployments on Google Cloud Platform, then an easy way of doing this is to use Jenkins. Jenkins is pretty good for automating your deployment processes.

Here we will discuss two ways of setting up Jenkins.

1). Using Cloud Launcher: This way is pretty straighforward but for some reason I was not comfortable using this method. The jenkins setup using the method eventually resulted into missing some important permissions / scopes and resulting into not letting me complete certain tasks within Jekins. But this method can still be useful for most of the use cases where you are not requiring custom scopes.

2). Launching Custom Compute Instance: In this method you have the luxury of setting up Jenkins with custom configurations. Using this method I was able to configure custom scopes which solved my initial problem faced in using first method.


Here I assume that you are aware of the basic use of Google Cloud platform and you already have the following things ready:-

  • You have created a Google Cloud Platform project.
  • You have enabled Compute Engine API over this project.
  • You have enabled Container Engine API over this project.

PS: These are quite easy to setup things. I will try to add another article to cover the Google Cloud Platform basics separately.

Method # 1 – Cloud Laucher

Google Cloud Platform provides ready to use compute instances that are pretty easy to launch. Just expand the left side bar menu and click on ‘Cloud Launcher’.

This will open an interface having a list of launch-able applications. Not all of them will be visible on the first screen. You can search for ‘Jenkins’ though.

From here onwards, its kind of a wizard. You can follow the instructions and complete the setup.

Method # 2 – Using Custom Compute Instance

While your project is selected, open the cloud shell.

Paste in the following command

gcloud compute instances create bitnami-jenkins --project $PROJECT_ID --image-project bitnami-launchpad --image $IMAGE_NAME --zone us-central1-a --machine-type n1-standard-1 --metadata "bitnami-base-password=$PASSWORD,bitnami-default-user=user,bitnami-key=jenkins,bitnami-name=Jenkins,bitnami-url=//,bitnami-description=Jenkins,startup-script-url=" --scopes ",,,," --tags "bitnami-launchpad"

$PROJECT_ID is the ID of your project.

$IMAGE_NAME is the name of image that you are accessing remotely. Following is how you can get this:-

Run the following command in cloud shell.

gcloud compute images list --project bitnami-launchpad | grep jenkins

$PASSWORD is the password. Whatever you will set here, you will use that while loging into your Jenkins web app. We are using username as ‘user’ but you can change that too.

Anyways a sample variables substitued command should look like the following:-

gcloud compute instances create bitnami-jenkins --project ci-test-project-170007 --image-project bitnami-launchpad --image bitnami-jenkins-2-46-3-0-linux-debian-8-x86-64 --zone us-central1-a --machine-type n1-standard-1 --metadata "bitnami-base-password=my_password,bitnami-default-user=user,bitnami-key=jenkins,bitnami-name=Jenkins,bitnami-url=//,bitnami-description=Jenkins,startup-script-url=" --scopes ",,,," --tags "bitnami-launchpad"

When you will run the above command, it will start a new VM instance for you.

Click on the name of the instance and then click Edit on top of the screen. Now make sure that ‘Allow HTTP traffic’ and ‘Allow HTTPS traffic’ options are checked under ‘Firewall’ settings. This will let your instance be accessible publically using its external IP Address.

You can now click on the external IP Address of your instance to open the Jenkins web app in browser.

Leave a Reply

Your email address will not be published. Required fields are marked *