Skip to Content

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

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

Prerequisites

  • Step 1

    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.

    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.

  • Step 2
  • Step 3
    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
  • Step 4

    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.

  • Step 5
    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.

  • Step 6
    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 GitHub credentials (github as created in step Configure you GitHub credentials above) 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. For Build Tool Version, select the latest version.

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

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

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

    15. Leave Acceptance Stage switched off.

    16. Under the Release section, switch the execution of the Deploy to Cloud Foundry Space step on.

      CAP Job
    17. 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
    18. For Credentials, choose the name of the credentials you created before in step Configure your SAP BTP credentials. 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.

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

    20. Choose Create.

  • Step 7

    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
  • Step 8

    You have to change the specVersion parameter in files ui5-deploy.yaml and ui5.yaml in both the app/risks and app/mitigations folders to 2.3. Otherwise, you might get an error when your job is built.

    1. Open the app/risks/ui5-deploy.yaml file and set the specVersion to 2.3:

      YAML
      Copy
      # yaml-language-server: $schema=https://sap.github.io/ui5-tooling/schema/ui5.yaml.json
      specVersion: '2.3'
      metadata:
          ...
      
    2. Open the app/risks/ui5.yaml file and set the specVersion to 2.3:

      YAML
      Copy
      specVersion: '2.3'
      metadata:
          ...
      
    3. Open the app/mitigations/ui5-deploy.yaml file and set the specVersion to 2.3:

      YAML
      Copy
      # yaml-language-server: $schema=https://sap.github.io/ui5-tooling/schema/ui5.yaml.json
      specVersion: '2.3'
      metadata:
          ...
      
    4. Open the app/mitigations/ui5.yaml file and set the specVersion to 2.3:

      YAML
      Copy
      specVersion: '2.3'
      metadata:
          ...
      
    5. Commit the changes to your GitHub repo.

  • Step 9

    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 service instance is running. Your SAP HANA Cloud service 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?

Back to top