Skip to Content

Configure and Run a Predefined SAP Continuous Integration and Delivery (CI/CD) Pipeline

test
0 %
Configure and Run a Predefined SAP Continuous Integration and Delivery (CI/CD) Pipeline
Details

Configure and Run a Predefined SAP Continuous Integration and Delivery (CI/CD) Pipeline

August 5, 2021
Created by
July 2, 2021
Enable SAP Continuous Integration and Delivery (CI/CD) service on SAP Business Technology Platform for your CAP application.

You will learn

  • How to enable SAP Continuous Integration and Delivery (CI/CD)
  • How to configure a CI/CD pipeline
  • How to create a GitHub webhook
  • How to run the CI/CD pipeline that automatically builds, tests, and deploys your code changes
QR code

Prerequisites


Step 1: Introduction

SAP Continuous Integration and Delivery (CI/CD) is a service on SAP BTP, which lets you configure and run predefined continuous integration and delivery pipelines. It connects with your Git SCM repository and builds, tests, and deploys your code changes. In its user interface, you can easily monitor the status of your builds and detect errors as soon as possible, which helps you prevent integration problems before completing your development.

SAP Continuous Integration and Delivery has a ready-to-use pipeline for CAP, that is applicable to multi-target application (MTA) and Node.js based projects. It does not require you to host your own Jenkins instance and it provides an easy, UI-guided way to configure your pipelines.

For more information on how to configure and run predefined pipelines for your own CI/CD process, have a look at What Is SAP Continuous Integration and Delivery.

Log on to answer question

Step 2: Enable SAP Continuous Integration and Delivery service
  1. Go to your SAP BTP cockpit by using one of the following links, depending on the landscape you want to use:

    https://cockpit.hanatrial.ondemand.com/

  2. Choose your Global Account.

  3. Navigate to your Subaccount.

  4. Choose Service Marketplace in the left-hand pane.

  5. Type Continuous Integration & Delivery in the search box and choose the service tile.

    Service Tile
  6. Choose Create.

    Service Tile
  7. Choose Create in the popup without changing any values.

    Popup
  8. Choose View Subscription and wait until the status changes to Subscribed.

    SubscriptionsSubscribed
  9. In your SAP BTP subaccount, choose SecurityRole Collections in the left-hand pane.

  10. Choose role collection CICD Service Administrator.

  11. Choose Edit.

    Role
  12. In the Users section, enter your e-mail address in the fields ID and E-Mail.

  13. Select an Identity Provider.

    Users

    Keep the setting Default Identity Provider unless you have a custom identity provider configured.

  14. Choose Save.

    See Initial Setup for more details on how to enable the service.

  1. Go to your SAP BTP cockpit by using one of the following links, depending on the landscape you want to use:

    https://account.hana.ondemand.com/

  2. Choose your Global Account.

  3. Navigate to your Subaccount.

  4. Choose Service Marketplace in the left-hand pane.

  5. Type Continuous Integration & Delivery in the search box and choose the service tile.

    Service Tile
  6. Choose Create.

    Service Tile
  7. Choose Create in the popup without changing any values.

    Popup
  8. Choose View Subscription and wait until the status changes to Subscribed.

    SubscriptionsSubscribed
  9. In your SAP BTP subaccount, choose SecurityRole Collections in the left-hand pane.

  10. Choose role collection CICD Service Administrator.

  11. Choose Edit.

    Role
  12. In the Users section, enter your e-mail address in the fields ID and E-Mail.

  13. Select an Identity Provider.

    Users

    Keep the setting Default Identity Provider unless you have a custom identity provider configured.

  14. Choose Save.

    See Initial Setup for more details on how to enable the service.

Log on to answer question

Step 3: Access Continuous Integration and Delivery service
  1. In your SAP BTP subaccount, navigate to ServicesInstances and Subscriptions in the left-hand pane.

  2. Choose the Go to Application icon located next to the Continuous Integration & Delivery subscription.

    CICD
  3. Use your credentials to log in to the application.

    CICD App
Log on to answer question

Step 4: Configure your GitHub credentials

To earn your badge for the whole mission, you will need to mark all steps in a tutorial as done, including any optional ones that you may have skipped because they are not relevant for you.

If your GitHub repository is not private, you can skip this section. If your GitHub repository is private, configure credentials for it, so that SAP Continuous Integration and Delivery service can connect to it.

  1. Navigate to the Credentials tab in SAP Continuous Integration and Delivery.

  2. Choose + to create credentials.

    Credentials
  3. For Name, enter a freely chosen name for your credential, which is unique in your SAP BTP subaccount. In this example, the name of the credential is github.

  4. As Type, select Basic Authentication.

  5. For Username, enter your GitHub username.

  6. For Password, use a personal access token.

    Select repo as scope when creating the token.

  7. Choose Create.

Log on to answer question

Step 5: Configure your SAP BTP credentials
  1. To create credentials for deploying to SAP BTP, Cloud Foundry environment, go to the Credentials tab and choose + (Create Credentials).

    Credentials
  2. For Name, enter a freely chosen name for your credentials, which is unique in your SAP BTP subaccount, for example cfdeploy.

  3. As Type, select Basic Authentication.

  4. For Username, enter your username for the SAP BTP cockpit.

  5. For Password, use your password for the SAP BTP cockpit.

    Credentials GitHub
  6. Choose Create.

Log on to answer question

Step 6: Configure a CI/CD job
  1. In the Jobs tab in SAP Continuous Integration and Delivery, choose + to create a new job.

    Jobs
  2. For Job Name, enter a freely chosen name for your job, which is unique in your SAP BTP subaccount, for example RiskApplication.

  3. Under Repository, choose Add Repository.

    Add repository
  4. Add the name and the URL for your repository.

    Add repository

    If your GitHub repository is private, enter the name of the credentials in Repository Credentials to access your GitHub Repository that you have already created. If your GitHub repository isn’t private, leave this field empty.

  5. Choose Add.

  6. For Branch, enter the GitHub branch of your repository from which you want to receive push events. In this example, main.

  7. As Pipeline, choose SAP Cloud Application Programming Model.

  8. Keep the default values in the BUILD RETENTION tab.

  9. In the STAGES tab, choose Job Editor from the Configuration Mode dropdown list.

  10. For Build Tool, leave mta as preselected.

  11. Leave the execution of the Maven Static Code Checks step switched off.

  12. Leave the execution of the Lint Check step switched off.

    CAP Job
  13. Leave the execution of the Additional Unit Tests switched off.

  14. Switch the execution of the Release stage on.

  15. Switch the execution of the Deploy to Cloud Foundry step on.

    CAP Job
  16. Replace the placeholders <YOUR ORG NAME>, <YOUR SPACE NAME>, and <YOUR CLOUD FOUNDRY API ENDPOINT> with the values of the space in the Cloud Foundry environment to which you want to deploy. You can get the values from your subaccount overview in the SAP BTP cockpit.

    Cockpit

    Credentials is the name of the credentials you have created before for SAP BTP access. In the example we used cfdeploy.

    Use a technical user instead of your personal credentials.

    Deployment will not work if you have activated Two-factor authentication for the user.

  17. Leave the Upload to Cloud Transport Management step switched off.

  18. Choose Create.

Log on to answer question

Step 7: Create a GitHub webhook

GitHub webhooks allow you to automate CI/CD builds. Whenever you push changes to your GitHub repository, a webhook push event is sent to the service to trigger a build of the connected job.

To create a webhook in GitHub, you need some data that has been automatically created during the previous step. You can find this data, the Payload URL and Secret, when you open the detail view of an existing repository in the Repositories tab.

  1. Choose the name of your repository and choose Webhook Data.

    Webhook

    You will see a popup like this:

    Webhook
  2. In your project in GitHub, go to the Settings tab.

  3. From the navigation pane, choose Webhooks.

  4. Choose Add webhook.

    Webhook
  5. Enter the Payload URL, Content type, and Secret from the Webhook Data in SAP Continuous Integration and Delivery. For all other settings, leave the default values.

  6. Choose Add webhook.

    Webhook Details
Log on to answer question

Step 8: Verify the success of your build

You have to trigger your job manually the first time after creation.

  1. In the Jobs tab in SAP Continuous Integration and Delivery, select your job and choose Trigger Build.

    Trigger Job

    Verify that a new tile appears in the Builds view. This tile should be marked as running.

    Job

    If you would like to check whether the job is triggered automatically after new changes, you can make a simple change in the code and verify if it’s built.

  2. Wait until the job has finished and verify that the build tile is marked as successful.

    Successful Build

    In case you get any errors:

    Verify that your SAP HANA Cloud instance is running. Your SAP HANA Cloud instance will be automatically stopped overnight, according to the server region time zone. That means you need to restart your instance every day, before you start working with your trial.

    Verify you have added all necessary entitlements to your account as specified in Prepare for SAP BTP Development.

  3. Navigate to your space in the SAP BTP Cockpit and check the list of installed applications. Now, you have a cpapp-db-deployer application and a cpapp-srv application.

    Applications
  4. Choose the cpapp-srv application and launch it with the application route.

    Cpapp Srv Route

You have now successfully created a CI/CD pipeline and deployed your application to SAP BTP.

Additional Information:

If you’d like to add more stages to your job, for example, additional unit tests, you can configure the job in your repository instead of using the job editor of the SAP Continuous Integration and Delivery. See Configure an SAP Cloud Application Programming Model Job in Your Repository for more details."

In case this is your first deployment of the cpapp project to the SAP BTP Cloud Foundry environment, please continue with the tutorial Add the SAP Launchpad Service. You will need to complete the configuration before you can use the application, because this part can’t be automated with CI/CD tooling.

How is a CI/CD build triggered?
×

Give us 55 seconds of your time to help us improve


Next Steps

Back to top