Skip to Content
Author's profile photo Andreas Gautsch

ABAP Continuous Integration with Jenkins

Short read

In this blog I describe how to set up a first minimal Continuous Integration environment for ABAP with Jenkins.

Therefore an Odata-Service on the Netweaver system is created which returns whether all tests of a package are successful or not. A step by step documentation of the creation with SAP Gateway can be found here.

On the Jenkins side you need on top of the default installation only additionally the HTTP Request plugin. The fiels of the request plugin are filled with the url of the created Odata-Service, valid credentials to connect to your SAP system and a simple configuration to process the received response.

After completing this you can use the standard features of Jenkins to setup a daily test run and notify for example a group of people if tests are broken. Welcome to the world of CI 🙂

Long read

In the recent years there were a lot of helpful things introduced in the ABAP universe. ABAP in Eclipse as the new development environment and also cool new language features like table expressions or enums.

One important thing I am still missing is a tooling for a Continuous Integration environment (short CI). Unit tests are there in ABAP since a long time and also frequent commits to a common repository are moreless standard when developing in ABAP.

Having Unit tests is great but do you really continuously check
if they aren’t broken? 

The first step in a Continuous Integration environment is mostly a daily build and testrun. Therefore the open source tool Jenkins is perfect.

The necessary steps to get your ABAP packages continuously tested by Jenkins are:

  1. Create an OData Service on the SAP Netweaver OData Service
  2. Installation of Jenkins
  3. Add the HTTP Request plugin
  4. Add a Jenkins user with the SAP credentials
  5. Configure the HTTP Request plugin inside a build
  6. Initial run and scheduling

OData Service on the SAP Netweaver OData Service

The creation of an Odata service which delivers the result whether all unit tests of a package are valid or not is described here.

Installation of Jenkins

The installation of Jenkins is rather straightforward. The latest version can be downloaded from https://jenkins.io/. Download, install and it is already up and running.

Add the HTTP Request plugin

To access the Odata Service from Jenkins the HTTP Request plugin is used. The plugin can be installed in Jenkins via the Plugin Manager. On the tab “Available” the plugin can be found in the endless list by using the filter tab on the right side.

Add a Jenkins user for the SAP access

To access the Odata Service of the SAP system a valid SAP user is needed. The user is configured as Jenkins user under the Credentials menu. The important fields are username and password.

 

Configure the HTTP Request plugin inside a build

The main feature of Jenkins is configuring different jobs which perform certain  tasks called build steps and deliver a message if all build steps where completed successfully.

In our case only one build step is needed. Calling of the Odata-Service for test execution with the Http Request plugin.

As parameters the plugin has to be packed with

  1. Url – the entire url of the Odata Service with the package as key (in the case below the name of the ABAP package is ZABAP_CI
  2. HTTP mode – GET
  3. Authenticate – select the jenkins credential which holds the SAP-credentials
  4. Response code expected – you can stay with the default values, I prefer to use the status code 200 only.
  5. Reponse content expected – this is important. The value has to be as shown in the screenshot, exactly the string TESTRUN_OK.

Initial run and scheduling

You can run the build manually on the right side with the menu entry build. The usual way is to configure a scheduling with cron expressions – thus the job is run automatically each day, each hour or …

Below you see the cron expression to start the Job each day at 7 am. But there are infinitive configuration possiblities like starting more times a day or only on weekdays.

On the bottom of the job configuration you can setup notifications, for example that an email is sent in the case the build did not deliver the expected result, in this case if the build does not contain the string “TESTRUN_OK”.

Enjoy your daily build. 🙂

Assigned Tags

      5 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Timo John
      Timo John

      Hi Andreas,

      interesting aproach for CI with ABAP. I really like that you also came across with a #ADT plugin! great Work!

      We do not - unfortunately - use unit tests very wide ... not even #ATC ... for several reasons.

      For those who will not have the time to setup #Jenkins etc, there ist a SAP report that runs #ABAPUnit tests an sends Mails :RS_AUCV_RUNNER might be helpful.

      Author's profile photo Andreas Gautsch
      Andreas Gautsch
      Blog Post Author

      Hei Timo!

      Thanks. I am still at the beginning with the abapCI plugin, lets see how far it evolves.

      The usage of Jenkins is in my opinion is only an option to keep in mind if you want to ensure the CI over an entire stack which includes also not ABAP parts. For an Netweaver only system there are already plenty of tools to ensure software quality - thanks for pointing out the Testrunner above.

      But there are two working situations I like to have Jenkins also taking care of the ABAP development packages.

      • To have the state of all software packages (ABAP and others) visualized in one screen (for example for checking each morning)
      • To be able to trigger immediately the automatic testing of all dependent not-SAP software components when an ABAP-package change is done.
        (this could be initialised directly in ABAP in Eclipse if you have a Job for your ABAP package - also if it is only a dummy job without the ABAP connection described above)

      Greetings, Andreas

      Author's profile photo Johannes Konings
      Johannes Konings

      Hi Andreas Gautsch ,

      Jenkins in combination with abapGit would be a great approach for continuous integration. Do you have already experience with additional checks next to ABAP Unit like the ATC for example?

      best regards

      Johannes

      Author's profile photo Andreas Gautsch
      Andreas Gautsch
      Blog Post Author

      Hi Johannes.

      The best approach I currently know is described in a blog from last november, but I think you are already aware of this:
      https://blogs.sap.com/2017/11/11/continuous-integration-in-abap-using-jenkins/

       

      Regards, Andreas

       

      Author's profile photo Johannes Konings
      Johannes Konings

      I hoped you had an approach with an easy http call from jenkins and the ATC is triggered through ABAP like your ABAP Unit approach :).
      So I will try the approach from the blog that you mentioned.