Setup Jenkins on SAP Cloud Foundry

Introduction of Cloud Foundry on SAP Cloud Platform enables a lot of possibilities to deploy various applications on the cloud. Jenkins is one of the most asked and some people may struggle to find a place to run it.

In this blog, I’ll show how to deploy Jenkins on Cloud Foundry environment on SAP Cloud Platform.

Download Jenkins.war

Go to https://jenkins.io/download/ and download Generic Java Package (war) of the version you prefer.

Deploy Jenkins on Cloud Foundry

Login

Connect to Cloud Foundry using CLI. (See how to download here).

cf api https://api.cf.eu10.hana.ondemand.com
cf login

Deploy Jenkins

We’re going to deploy Jenkins.war using this special buildpack.

cf push <path_to_jenkins.war> -b https://github.com/Altoros/jenkins-buildpack -m 2G <unique_app_name>

Here is what it looks like for me:

$ cf push -p Downloads/jenkins.war -b https://github.com/Altoros/jenkins-buildpack -m 2G jenkins-chairat
Creating app jenkins-chairat in org P1941180417trial_trial / space dev as pacroy@gmail.com...
OK
Creating route jenkins-chairat.cfapps.eu10.hana.ondemand.com...
OK
Binding jenkins-chairat.cfapps.eu10.hana.ondemand.com to jenkins-chairat...
OK
Uploading jenkins-chairat...
Uploading app files from: /var/folders/z9/509z92q528g_vyl_l8g72s7w0000gn/T/unzipped-app082759293
Uploading 21.6M, 1177 files
Done uploading
OK
Starting app jenkins-chairat in org P1941180417trial_trial / space dev as pacroy@gmail.com...
Creating container
Successfully created container
Downloading app package...
Downloaded app package (69.9M)
Staging...
cat: /tmp/buildpackdownloads/33bbc852fcb5b983f2ec3eef5d6759f4/VERSION: No such file or directory
-------> Buildpack version
-----> Extracting JRE.
/tmp/app/vendor ~
-----> Moving jre1.8.0_102 to target folder.
~
-----> Repacking jenkins.war.
/tmp/app ~
~
-----> Building runtime environment.
-----> Done.
Exit status 0
Staging complete
Uploading droplet, build artifacts cache...
Uploading build artifacts cache...
Uploading droplet...
Uploaded build artifacts cache (131B)
Uploaded droplet (207.3M)
Stopping instance b61f17b6-70bc-4547-aeae-9e789a2f5279
Uploading complete
Destroying container
Successfully destroyed container
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
1 of 1 instances running
App started
OK
App jenkins-chairat was started using this command `java -jar jenkins.war --httpPort=$PORT`
Showing health and status for app jenkins-chairat in org P1941180417trial_trial / space dev as pacroy@gmail.com...
OK
requested state: started
instances: 1/1
usage: 2G x 1 instances
urls: jenkins-chairat.cfapps.eu10.hana.ondemand.com
last uploaded: Sun Oct 22 03:06:18 UTC 2017
stack: cflinuxfs2
buildpack: https://github.com/Altoros/jenkins-buildpack
state     since                    cpu      memory       disk           details
#0   running   2017-10-22 10:08:12 AM   160.3%   1.1G of 2G   427.7M of 1G

Login to Jenkins

Once the instance is up and running, go to the app’s URL as indicated above.

It will ask you to enter administrator password.

Find your password with this command:

cf logs jenkins-chairat --recent | grep -B 1 -A 2 "following password"

Proceed the installation by installing suggested plugins.

In the last step, create an account and the Jenkins will be ready to use.

References

Like what you read? Give Chairat Onyaem a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.