Managing the Application's Lifecycle with CI/CD Service

Objective

After completing this lesson, you will be able to manage the application's lifecycle with CI/CD services

Enable the Continuous Integration and Delivery (CI/CD) Services

Business Scenario

We're in the process of developing a cloud application based on a variety of SAP Technologies. These are: database services, user interfaces, including SAP Cloud Application Programming Model (CAP), SAP Fiori, SAP Mobile Development Kit (MDK), and others. As the project becomes more complex, more developers need to collaborate and contribute to the project. Therefore, an efficient way to enable continuous integration and delivery on the project is needed to ensure quality. Smooth development can be achieved with an automated build and testing repository. In this case, the SAP Continuous Integration and Delivery service is used to achieve that.

In this exercise, you perform the following tasks:

  • Create a CI/CD job on your project.
  • Configure your CI/CD job to build, and deploy your application to a test Cloud Foundry environment.
  • Triggering an automated CI/CD build by submitting a change to your remote Git repository.

Prerequisites

  • You must first subscribe to the SAP Continuous Integration and Delivery service, and assign the required roles and permissions. See Initial Setup
  • You have successfully completed the exercises up to Create User Roles.
  • You have shared your project to a remote Git repository.

Note

Note that some of the services that this learning journey links to can incur costs.

If you are concerned about charges, you can opt to skip the corresponding exercises and watch the simulation instead.

Exercise Options

You can perform this exercise in two ways:

  1. Live Environment: by using the instructions provided below, you can perform the steps in your SAP BTP account.
  2. Platform Simulation: follow the step-by-step instructions within the simulation.

Note

We strongly recommend performing the steps in the live environment first.

The following simulation reproduces the full exercise execution:

Task 1: Enable Continuous Integration and Delivery (CI/CD)

Steps

  1. Enable Continuous Integration and Delivery (CI/CD).

    1. Choose the CI/CD button from the left panel.

      System screenshot
    2. If you can't see the CI/CD icon, you can open the menuViewCI/CD.

      System screenshot
    3. Check your project In the CI/CD panel. It should have no jobs yet, and a Create Job button. Choose the Create Job button.

      System screenshot

      Note

      If you have not shared your project to a remote Git repository, you get a notification message that will ask you to share your project.

    4. The Guided Development page displays. Scroll down to see the topic: Create a CI/CD Job, and expand Job Configuration.

      System screenshot
    5. Choose the Configure Job button, and a new Job Configuration wizard opens to let you create and configure a new job.

    6. In the Job Name step, enter a unique job name.

    7. From the Pipeline dropdown list, select SAP Cloud Application Programming Model.

      System screenshot
    8. Choose Next.

  2. In the Git Credentials step, add a repository and credentials.

    You will store your remote Git repository to the SAP Continuous Integration and Delivery service so that it can retrieve your project via Git to do the build and deployment.

    Use the following data:

    FieldValue
    Repository name(of your choice)
    Credential(of your choice)
    Description(of your choice)

    1. You should not have any matching Git Repositories for selection yet, so select -- Add a Repository -- from the Git Repositories dropdown list. Two new fields should appear: Repository Name and Git Credentials.

    2. Give the repository a unique name in the Repository Name field. This is the name to identify your repository that's stored in the SAP Continuous Integration and Delivery service.

    3. You should not have any Git credentials that you can use yet, so select -- Add Credentials -- from the drop down list.

    4. Give the credential a unique name that is stored in the SAP Continuous Integration and Delivery service, for example: user-abc-github.

    5. You can also give some description to better describe the credential, for example User Abc's Github.com credentials.

    6. Enter the user name and password / token. These two fields are securely stored in the SAP Continuous Integration and Delivery service, and will be used by the service to access and retrieve the project from your Git repository.

      System screenshot
    7. Choose Next to continue to the next step.

  3. In the Acceptance step, perform the steps to create further credentials.

    This step allows you to specify the Cloud Foundry environment you wish this project to be deployed to for acceptance testing.

    1. Select Yes in the radio button.

    2. Enter the API Endpoint, Org Name, Space, and Cloud Foundry Credentials (You might need to specify).

      To find the required information, navigate back to your subaccount and scroll down to Cloud Foundry Environment.System screenshot

    3. You should not have any Cloud Foundry credentials yet, so select -- Add Credentials -- from the dropdown list.

    4. Give the credential a unique name that is stored in the SAP Continuous Integration and Delivery service, for example: user-abc-cf.

    5. You can also give some description to better describe the credential, for example User Abc's Cloud Foundry credentials.

    6. Enter the username and password / token. These two fields will be stored securely in the SAP Continuous Integration and Delivery service, and will be used by the service to deploy your application to the Cloud Foundry target that you have specified.

      System screenshot
    7. Choose Next to continue to the next step.

  4. In the Release step, there is nothing to do.

    This step allows you to configure the deployment to Cloud Foundry and / or to the Cloud Transport Management Service.

    1. In this exercise, we will neither set up this job to release to Cloud Foundry, nor upload to Cloud Transport Management Service, so we can leave them as No and choose Finish to complete the job creation.

    2. Once the job creation is done, you should see the following notifications:

      System screenshot
    3. You should see that a job is now visible in the CI/CD panel. But at the moment, it will have no job run history.

      System screenshot
  5. The Webhook Data tab should have opened automatically on completion of the CI/CD job creation. If not, you can follow alternatively one of the following substeps.

    1. Choose the Overflow button beside the job name to open a context menu.

    2. Choose the View Webhook menu item.

      This opens a Webhook Data tab with the required details for adding webhook data.System screenshot

  6. Perform Settings in GitHub.

    1. Navigate to your Git repository and choose Settings(Code and Automation) HooksAdd webhook.

      System screenshot
    2. In the Payload URL field, paste the Payload URL from the Webhook Data tab.

    3. Set Content type to application/json.

    4. In the Webhook Data tab, select Create a new secret.

    5. Select Yes when asked for confirmation.

    6. In the Secret field, paste the Secret from the Webhook Data tab.

    7. Select Add webhook.

  7. Submit the changes to the remote Git repository.

    Now, according to the notification we saw earlier, we have to submit any changes to the remote Git repository before triggering a build.

    1. In SAP Business Application Studio, open the storyboard

    2. For the data model entry Risks select Edit Sample Data.

      System screenshot
    3. In the Sample Data Editor change the Prio in the first row from 1 to 2.

      System screenshot
    4. From the activity bar, navigate to Simplified Git.

    5. Add in a message and select Commit & Sync.

    6. From the activity bar, navigate back to CI/CD.

      You will find that a build is triggered and the following notifications are generated:

      System screenshot

      Note

      In case the build is not triggered automatically, please do the following:

      1. Choose the Overflow button beside the job name to open the context menu.
      2. Choose Trigger a build.
      3. In the confirmation dialog, you can choose whether you want your builds to be triggered automatically or manually in the future upon committing changes to your Git repository. System screenshot
    7. You will see the job status changed from No build history to Build 1 with StatusRunning:

      System screenshot
    8. Depending on your project size and your job configuration, the build will probably take at least 5 minutes or more. Once the build completed, you will receive a notification such as the following:

      System screenshot
    9. Your job status in the CI/CD panel will be updated for example:

      System screenshot

Reference Links: Services for Continuous Integration and Delivery (CI/CD)

You find more information about continuous integration and delivery here: Continuous Integration and Delivery

Log in to track your progress & complete quizzes