Skip to Content

Every serious software project needs automated continuous integration builds. Especially for cloud applications, this is not so difficult: the whole process from building via deployment to final testing can be automated easily. The usual tool for automating continuous integration builds is Jenkins.

In this blog, I describe how to set up a Jenkins running on the SAP HANA Cloud Platform that performs continuous integration builds for a cloud application. Of course I will use the famous “Hello World” as an example – this time in an SAP HANA Cloud edition. You find the sources of the “Hello World” project on GitHub. It is a slightly modified version of the “Hello World” example in the SAP HANA Cloud SDK.

You will learn how to create a Jenkins build job that fetches the sources from GitHub and builds them with Apache Maven. The maven build of the “Hello World” project creates, deploys and starts a “Hello World” application in a developer account on the SAP HANA Cloud Platform. This Maven build also executes an integration test against the running “Hello World” application and stops it afterwards.

What are the prerequisites?

You have to use two developer accounts on the SAP HANA Cloud Platform, one for Cloud Jenkins and one for “Hello World”. A developer account is restricted to run only one application at one time. This is a good opportunity for doing pair programming, isn’t it?

In short, you need Apache Maven 3.0.4 or newer, Git, two developer accounts on the SAP HANA Cloud Platform and the SAP HANA Cloud SDK 1.51.16. Unzip the SAP HANA Cloud SDK to a directory neo-sdk-javaweb-1.51.16. The SDK contains the neo command line tool that you need for deploying later.

If you want to dig a little deeper: You can find a very well and detailed description on how to setup your developer workspace and account in Jens Glander’s SAP HANA Cloud Application Development Scenario End-to-End Tutorial.

By the way, I prefer to use a “Git Bash” as console and so I will stick to unix style in the command line examples listed below.

Jenkins In The Cloud

The original Jenkins distribution that can be downloaded from http://jenkins-ci.org/ doesn’t run well on SAP HANA Cloud. It does work, but it doesn’t survive restarts. Jenkins works with the file system but there is no persistent file system available in the developer accounts of the SAP HANA Cloud Platform. After an application restart, everything stored on the file system will be lost.

The Cloud Jenkins overcomes this limitation by storing the configuration in the document service of the SAP HANA Cloud Platform. Besides providing Jenkins in the cloud, this is also a good example of how other applications could cope with the absence of a persistent file system.

The necessary Jenkins plugin that integrates Jenkins with the SAP HANA Cloud Platform is implemented in the cloud-jenkins project. So the first step is to build the cloud-jenkins project to convert a standard Jenkins into a cloud enabled Jenkins.

First you clone the “sap/cloud-jenkins” project from Github. In a console you go to your workspace directory and enter

git clone https://github.com/SAP/cloud-jenkins cd cloud-jenkins

Then you build the Cloud-Jenkins project. with Maven. The project depends on artifacts which can be found in repo.jenkins-ci.org/public. You make sure that Maven can reach this repository e.g. by adding it to your Maven “settings.xml”. Most likely this is located at “${user.home}/.m2/settings.xml”. If you are behind a firewall you need to configure a proxy in the “settings.xml” file, too. If not you can skip the proxy entry.

<proxies>

  <proxy>

      <protocol>http</protocol>

      <host>proxy.somewhere.com</host>

      <port>8080</port>

      <username>proxyuser</username>

      <password>somepassword</password>

      <nonProxyHosts>localhost</nonProxyHosts>

  </proxy>

</proxies>

<repositories>

    <repository>

      <id>repo.jenkins-ci.org</id>

      <url>http://repo.jenkins-ci.org/public/</url>

  </repository>

</repositories>

<pluginRepositories>

    <pluginRepository>

      <id>repo.jenkins-ci.org</id>

      <url>http://repo.jenkins-ci.org/public/</url>

  </pluginRepository>

</pluginRepositories>

You let Maven create the file “cloud-jenkins-webarchive/target/ROOT.war” by simply calling

mvn clean install

The next step is to deploy the web archive to the developer account on the SAP HANA Cloud Platform. This is easily done with the neo command line tool. Remember: It is part of the SAP HANA Cloud SDK and located in its “tools” sub folder. If you are behind a proxy you have to set the following environment variables before you execute the neo command.

export http_proxy=http://<HTTP proxy hostname>:<HTTP proxy port>

export https_proxy=https://<HTTPS proxy hostname>:<HTTPS proxy port>

export no_proxy=“localhost”

Let’s bring Jenkins to the cloud. In a console you invoke

<path to neo tool>/neo.sh deploy –host hanatrial.ondemand.com –account <your developer account> –application jenkins –user <your user ID> –source cloud-jenkins-webarchive/target/ROOT.war –uri-encoding UTF-8

You have to configure the permissions for the Cloud Jenkins deployment. So you go to the SAP HANA Cloud Platform cockpit. I assume you have a totally new developer account and so you expect your ‘jenkins’ application to be listed together with the ‘welcome’ application. Both are in the status stopped.

/wp-content/uploads/2013/10/cockpit_001_after_deploy_296145.jpg

On the “Authorizations” tab you enter user ID and click on “Show Roles”. Your user has to be assigned to the “admin” role of the “jenkins” application.

/wp-content/uploads/2013/10/cockpit_002_after_admin_role_config_296146.jpg

You start the “jenkins” application on the “Applications” tab. The application status page also shows the URL of the application.

/wp-content/uploads/2013/10/cockpit_004_after_start_296148.jpg

As a result, you get a running Jenkins instance. Click on the URL of the “jenkins” application, log in and have a look at the “Manage Jenkins” page.

/wp-content/uploads/2013/10/jenkins_002_manage_jenkins_overview_296150.jpg

Regard the cloud symbol. Your “jenkins” application has an additional plugin that provides the “Manage Jenkins Installation on Cloud” link.

With the “Manage Jenkins Installation on Cloud” UI you can
  • Upload files to Jenkins
    The provided zip archive is extracted to the home directory (~) of the user running the Jenkins instance. The JENKINS_HOME directory is in the “.jenkins” sub-directory. For example you can upload an archive with a file “.jenkins/jobs/<job name>/config.xml” to add a job with a configuration copied from a different Jenkins instance. You can even upload an archive with a “.m2/settings.xml” file to overwrite the global Maven settings.xml.
  • Delete files from Jenkins
    You can delete a file or a folder including its content. Again, the path must be relative to the home directory (~) of the user running the Jenkins instance.
  • Store the Jenkins configuration in the SAP HANA Cloud document service so that it survives a restart
    The selected files are stored in the SAP HANA Cloud document service. When the Jenkins application is restarted, the stored configuration is reloaded from the SAP HANA Cloud document service. You can specify which files are to store in the SAP HANA Cloud document service and you can use Ant style wildcards. Paths must be relative to the home directory (~) of the user running the Jenkins instance, e.g. “.jenkins/*.xml, .jenkins/jobs/*/config.xml, .jenkins/plugins/*.jpi, .m2/settings.xml”.
    You can also define an optional exclude pattern. Files matching this exclude pattern will not be stored in the SAP HANA Cloud document service. If you want to exclude the SAP HANA Cloud Jenkins plugin you would specify “.jenkins/plugins/cloud-jenkins.jpi”. In this case the version shipped with the Cloud Jenkins war file is used. Be aware that all files which have been stored last time and do not match the actual selection pattern anymore will implicitly be deleted from the document service with the new store action.
  • Restore the Jenkins configuration from the SAP HANA Cloud document service
    The result of this action is not a reset of the Cloud Jenkins file system to what one would get after an application restart. Instead it just brings back all content being stored in the document service and leaves the rest of the file system untouched – like e.g. new unsaved projects and the build history.
  • Download the Jenkins configuration
    The downloaded archive contains all the content that is stored in the document service – in your case the Jenkins configuration. This archive can for example be uploaded to a different Jenkins via ‘Upload files to Jenkins’.

/wp-content/uploads/2013/10/jenkins_003_manage_jenkins_installation_on_cloud_296151.jpg

Setting Up A Continuous Integration Build Job

As next step, you add a new build job on your Jenkins instance. As stated above this job shall sync a project from gitHub and build it with Maven. The project itself is configured to use the neo tool for deploying the application war file to the SAP HANA Cloud Platform and test it. Don’t hesitate to look at the “pom.xml” file and the code of Stephan Merker’s Cloud Helloworld example to see how this can be achieved. This project is based on the “hello-world” example from the SAP HANA Cloud SDK.

Create a new free-style software project job with the name “cloud-hello-world”. The project you want to build expects a set of environment variables. Be aware that you need the credentials from the second account now. Select “This build is parametrized” and add the following:

Parameter Type Parameter Name Default Value Description
String Parameter SAP_CLOUD_ACCOUNT <to do> Your account on https://account.hanatrial.ondemand.com
String Parameter SAP_CLOUD_USERNAME <to do> A user with deploy permission in your account
Password Parameter SAP_CLOUD_PASSWORD <to do> The password of the given user
String Parameter PROXY_HOST proxy-trial.od.sap.biz from Manage Jenkins -> System Information -> http.proxyHost
String Parameter PROXY_PORT 8080 from Manage Jenkins -> System Information -> http.proxyPort

/wp-content/uploads/2013/10/jenkins_005_new_job_cloud_hello_world_1of2_389369.jpg


Mark Git as “Source Code Management” and enter “https://github.com/stephanme/cloud-helloworld.git” as “Repository URL”. “Branch to build” has to be set to “**”. In the “Build” section you add a “Invoke top-level Maven targets” step. Select “Maven 3.0.5” as Maven version, let the goals be “clean verify -B -e -P cloud-integration-tests” and press the “Advanced” button. You have to mark “Use private Maven repository” and leave the rest of the parameters as they are.

/wp-content/uploads/2013/10/jenkins_006_new_job_cloud_hello_world_2of2_389485.jpg

After clicking the “Save” button at the bottom of the page the job is created. To view the configuration of this job on the Cloud Jenkins reference instance just go to https://jenkinsp1940131088trial.hanatrial.ondemand.com/job/cloud-hello-world/configure. Run the build job by clicking “Build With Parameters” and as you already specified all parameter’s default values, leave them as they are and just press “Build”.

/wp-content/uploads/2013/10/jenkins_007_build_cloud_hello_world_296155.jpg

The build should succeed, of course and the build log should end like

/wp-content/uploads/2013/10/jenkins_008_build_result_cloud_hello_world_296162.jpg

How do you assure that the new jobs are still available after an application restart when the file system is not persistent? The answer is very easy: By storing the configuration in the SAP HANA Cloud document service via “Manage Jenkins -> Manage Jenkins Installation on Cloud”. Click the “Store” button in the “Store Jenkins configuration in SAP HANA Cloud document service” section and confirm the files to store on the next screen.

Let’s see what happens after a restart if you stop and then start the Cloud Jenkins application. Go to the SAP HANA Cloud Platform Cockpit, stop the application “jenkins” and afterwards start it again.

After the restart all files that have not been persisted in the SAP HANA Cloud document service vanished. As a result the job “cloud-hello-world” is still there but looks like it did never run. The history and workspace of the job are lost.

/wp-content/uploads/2013/10/jenkins_011_after_restart_443935.jpg

Instead of manually triggering the build job you can poll for changes of your SCM project, install additional plugins and use all the other nice features that Jenkins provides. As you just saw you have to take care that all the files you need after an application restart were previously stored in the document service.

Here goes! Have fun with your CI Jenkins Server On SAP HANA Cloud.

Best regards, Stephan Weber

To report this post you need to login first.

14 Comments

You must be Logged on to comment or reply to a post.

  1. L. van Hengel

    Hi Stephan,

    Thanks for this blog. Already managed to do the installation yesterday when i noticed it on github. Installation works great. Now find some more time to investigate and start using it.

    Cheers,

    Leo

    (0) 
  2. Dobromir Zahariev

    Great article that describe some unusual scenario from my point of view. Anyway my second thought was – What the hell Jenkins is a simple java application, but the nodes that are used as executors are more interesting ๐Ÿ™‚

    Does the SAP HANA Cloud can handle also tests execution with UI (SWT Bot tests), or only can handle builds and headless unit tests?

    (0) 
  3. Matthias Steiner

    Thanks Stephan and team for this great blog post! It’s a very detailed step-by-step getting started guide and it addresses an important topic of cloud computing!

    Well done – looking forward to more ๐Ÿ™‚

    (0) 
  4. Manna Das

    Hello Matthias,

    thanks for sharing your wonderful knowledge. I have one question, is that possible to use one SAP Hana cloud one platform on multiple machines?

    (0) 
  5. Chris Paine

    After trying and failing multiple times today to deploy a 32Mb WAR to the HCP (timeouts – the internet connections in the CBD in Melbourne are overloaded, our connection is being throttled at the exchange) I’m thinking this is a great idea. Fortunately I have faster internet at home.

    One does have to wonder though, why isn’t this just a regular feature of the HCP anyway?!

    Will let you know how I go if I’m frustrated in the office tomorrow and try this out.

    Cheers,

    Chris

    (0) 
    1. Chris Paine

      So now in a situation where I’m building a productive app for a customer. LCM is important, that’s where Jenkins comes in. I’m in a quandary, it would be much cooler to have everything running on HCP, but an AWS box with Jenkins on it is a fair bit cheaper…

      (I have used AWS for Jenkins for other HCP projects, but this customer is particularly SAP centric).

      How long until this functionality is just part of the platform? Wouldn’t that be nice!

      Cheers,

      Chris

      (0) 
  6. Stephan Merker

    News & Noteworthy for https://github.com/SAP/cloud-jenkins

    • Replaced native git client by jgit. This saves some precious disk space and we could get rid of the install-git job that had to run on every Jenkins startup.
    • updated Jenkins to 1.532.2 (LTS version)

    When you update an existing Jenkins instance, you need to delete the ‘install-git’ job manually and re-configure the Git plugin to use jgit (Manage Jenkins > Configure System > Git).

    Best regards,

    Stephan

    (0) 
  7. Vedran Lerenc

    A bit off topic, but you may be interested to hear that SAP HANA Cloud Platform isn’t only shipping its SDK and API to Maven Central, but as of lately now also a Maven plugin is available.

    There are two new blog postings about the SAP HANA Cloud Platformartifacts shipped to Maven Central. You may like to check out Building Java Web Applications with Maven and Working with the “Neo” Maven Plugin.

    The first explains how to compile against the SAP HANA Cloud Platform API for Java and the second introduces the official Maven plugin for the SAP HANA Cloud Platform.

    API, SDK, and the new and official Maven plugin are continuously released to Maven Central. The help for the plugin can be found here:SAP HANA Cloud Platform Java Web Maven Plugin.

    (0) 
  8. Shwetank Verma

    Hi,

    While build m getting this error.. kindly help me resolve it —

    Building in workspace /usr/sap/ljs/home/.jenkins/workspace/cloud-hello-world

    Fetching changes from the remote Git repository

    Checking out Revision 3e172e26fed67aefcb7999cdfc586dda8d016ff5 (origin/master)

    [cloud-hello-world] $ mvn -DSAP_CLOUD_ACCOUNT=i300734trial ******** -DSAP_CLOUD_USERNAME=i300734 -DPROXY_PORT=8080 -DPROXY_HOST=proxy-trial.od.sap.biz -Dmaven.repo.local=/usr/sap/ljs/home/.jenkins/workspace/cloud-hello-world/.repository mvn clean install

    FATAL: command execution failed

    java.io.IOException: Cannot run mvn – execvpe failed (ENOENT – No such file or directory)

    Regards

    (0) 
  9. Wagner Alves da Silva Junior

    Hey guys, I noticed that this post was written a long time ago. I’m wondering if anyone has succeed using Jekins on HCP, using this tutorial. How was the experience using it daily in a real project?

    Best regards

    (0) 

Leave a Reply