Skip to Content
Author's profile photo Dirk Malchow

How to setup automated CI/CD Gitlab pipeline with SAP Cloud Foundry and a simple Go application

Not too long ago SAP launched the Cloud Foundry landscape on SAP Cloud Platform – a modern PaaS offering that gives you the possibility to develop in almost any modern programming language. Applications on SAP cloud platform connect with your on-premise SAP systems as well as SAP cloud solutions and even non SAP-products.

When you are developing cloud applications you probably have already heard at least here and there that Continous Integration (CI) / Continous Delivery (CD) is your development paradigm of choice. Wolfram Kramer already wrote about the general theory of CI/CD in this blogpost, so if you have any questions regarding CI/CD check out that blog post and come back afterwards to get your hands “dirty” with some CI/CD implementation.

In this blog post i want to share with you the initial setup of a CI/CD pipeline, in which a simple Go application will be developed and shipped through an automated pipeline to SAP Cloud Platform. Therefore i assume you are already familiar with CF CLI, Git, Go and Docker (since we will use multiple docker containers to execute the pipeline steps). Go by the way is an awesome language for Cloud Foundry, since we are leveraging the binary buildpack to run a Go application (rather than using the Go buildpack). I chose to use Gitlab as our git repository, since the free public service offering is offering us not only the CI/CD functionality for free but also 2,000 CI minutes on shared Runners. I would recommend this approach only to get a feel for CI/CD development…if you want to get serious about this consider hosting the Gitlab CE edition (which is free, or EES and EEP which would cost you) in your own environment with your own runners!

The pipeline shall:

  1. Compile the code
  2. Test the code
  3. Deploy the tested application to SAP Cloud Platform

If you have not done already, head over to and sign up. After signing up, create a new project called “myFirstGoAppOnSCP” (or whatever you find appropriate 🙂 ). Clone that repository to your local machine. At the moment, it should still be empty. Let’s put in some files! You can find my public gitlab repository with all necessary files under this link. Put all of those files into your cloned folder and commit them, don’t push them yet – let’s have a look at the .gitlab-ci-yml file first, since gitlab pipelines are configured in that file:


– build
– test
– deploy

image: golang:1.8
stage: build
– bin/
– export GOPATH=$PWD
– go install -v $APPNAME

image: golang:1.8
stage: test
– bin/
– export GOPATH=$PWD
– go test -v $APPNAME

image: pivotalpa/cf-cli-resource
stage: deploy
– bin/
– sh

The first part “variables” is only declaring some non-secret static variables, which we can use throughout that file. Next comes the definition of all our pipeline steps. As mentioned earlier, we want to first check if we can compile our main code base at all, then check if all our tests are passing and finally ship everything to SAP Cloud Platform.

All of these steps are executed on so called Runners. As already mentioned you have 2000 minutes on shared runners for free, if you have a public project on Docker is already installed on these runners and you can make use of that in your various steps….for the compile and test job, we will use the official Golang container from Google called “golang:1.8”, so all that all our compile and tests steps are always executed in the same, “official” environment with golang version 1.8. To ship our files to SAP Cloud Platform, we will use the container from pivotal called “pivotalpa/cf-cli-resource”. Both can be found on docker hub, but you are not limited to containers there. Just define your own docker repository and host your very own runner images there!

In each job a short script is defining what should be done in that job. So in the first script, you will find everything that should be done to compile Go code. It’s only two lines at the moment, so it’s pretty straight forward 🙂 Sharing files between jobs is simple, but has to be defined explicitly. In our example, we will share the compiled binary from step 1 so that it is accessible in step 3 for the deploymentprocess. Keep in my mind that you can define any command under the script area, so that also shells scripts can be executed. I’ve written a short shell script for the deploymentprocess which could definitily be enhanced with more complex logic – adapt it to your own needs and environments!

Now if you had a look at my little shell script you will see that i’m retrieving the credentials to connect with SAP Cloud Platform from environment variables. These credentials can be setup separately and do not belong under git version control, they should be maintained in Gitlab at project level from the project admin. So head over to Settings > Pipelines and scroll down a bit where you will find the area you are also seeing the screenshot below.

Environment Variable Setup

There, maintain the following settings

  1. CF_API_ENDPOINT: (for Frankfurt SCP CF landscape)
  2. CF_USER: (Your SCP user email adress)
  3. CF_PASS: (Your SCP user password)

Now you are ready to push your commit to your Gitlab git and see if our pipeline works! Ideally you should see what can be found in the screenshot below:

Pipeline overview

Click on the third job and check out the ouput:

Deploy output

Let’s check out the mentioned internet adress:

Hello World Page

Congratulations! You just launched you first Go application on SAP Cloud Platform with the help of a CI/CD pipeline. Go ahead and just change the output text of the http handler! While youre at it, don’t forget to change the test too – if you don’t, you’re pipeline will fail and nothing will be deployed. If you’ve changed both functions the automated pipeline should be finished after some minutes and you’re new app is already launched for you 🙂

This was just the bare minimum to get started with CI/CD on SAP Cloud Platform, familiarize yourself with different branches, merge requests, commit hooks and so on and so on….

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Helmut Tammen
      Helmut Tammen

      Wow Dirk!

      Awesome blog to demonstrate how up to date SAP and non-SAP products and technologies work hand in hand. It would be great to see my customers read and understand this blog and the opportunities that lie in these new cloud technologies.

      Thanks Helmut

      P.S. I'm currently working in Berlin two days a week. If you like to we can meet for a drink or a dinner in the evening and enthuse about the new SAP world. I'm working not far away from SAP Berlin subsidiary.