github.com/jaylevin/jenkins-library@v1.230.4/documentation/docs/scenarios/CAP_Scenario.md (about)

     1  # Build and Deploy SAP Cloud Application Programming Model Applications
     2  
     3  In this scenario, we will setup a CI/CD Pipeline for a SAP Cloud Application Programming Model (CAP) project.
     4  
     5  ## Prerequisites
     6  
     7  * You have the SAP Cloud Application Programming Model command line tool (cds-dk) installed: See [Get Started](https://cap.cloud.sap/docs/get-started/#local-setup).
     8  * You have setup a suitable Jenkins instance as described in [Guided Tour](../guidedtour.md)
     9  
    10  ## Context
    11  
    12  The Application Programming Model for SAP Business Technology Platform (SAP BTP) is an end-to-end best practice guide for developing applications on SAP BTP and provides a supportive set of APIs, languages, and libraries.
    13  For more information about the SAP Cloud Application Programming Model, visit its [documentation](https://cap.cloud.sap/docs/about/).
    14  
    15  ## Getting started
    16  
    17  To get started, generate a project using the SAP Cloud Application Programming Model command line tools:
    18  
    19  ```
    20  cds init bookshop --add java,mta,samples,hana
    21  ```
    22  
    23  Alternatively you can also reuse an existing project. To include support for continuous delivery, you can execute the command `cds add pipeline` in the directory in which you have created your project:
    24  
    25  ```
    26  cd bookshop
    27  cds add pipeline
    28  ```
    29  
    30  This will generate a project which already includes a `Jenkinsfile`, and a `.pipeline/config.yml` file.
    31  
    32  Now, you'll need to push the code to a git repository.
    33  This is required because the pipeline gets your code via git.
    34  This might be GitHub, or any other cloud or on-premise git solution you have in your company.
    35  
    36  Afterwards you can connect your Jenkins instance to your git repository and let it build the project.
    37  
    38  ## Legacy documentation
    39  
    40  If your project is not based on the _SAP Business Application Studio_ WebIDE template, you could either migrate your code to comply with the structure which is described [here](https://github.com/SAP/cloud-s4-sdk-pipeline/blob/master/doc/pipeline/build-tools.md#sap-cloud-application-programming-model--mta), or you can use a self built pipeline, as described in this section.
    41  
    42  ### Prerequisites
    43  
    44  * You have an account on SAP Business Technology Platform in the Cloud Foundry environment. See [Accounts](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/8ed4a705efa0431b910056c0acdbf377.html).
    45  * You have downloaded and installed the Cloud Foundry command line interface (CLI). See [Download and Install the Cloud Foundry Command Line Interface](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/afc3f643ec6942a283daad6cdf1b4936.html).
    46  * You have installed the multitarget application (MTA) plug-in for the Cloud Foundry command line interface. See [Install the Multitarget Application Plug-in in the Cloud Foundry Environment](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/27f3af39c2584d4ea8c15ba8c282fd75.html).
    47  * You have installed the Java Runtime Environment 8.
    48  * You have installed Jenkins 2.60.3 or higher.
    49  * You have set up Project “Piper”. See [README](https://github.com/SAP/jenkins-library/blob/master/README.md).
    50  * You have installed the multitarget application archive builder 1.0.6 or newer. See [SAP Development Tools](https://tools.hana.ondemand.com/#cloud).
    51  * You have installed Node.js including node and npm. See [Node.js](https://nodejs.org/en/download/).
    52  
    53  ### Context
    54  
    55  The Application Programming Model for SAP Business Technology Platform is an end-to-end best practice guide for developing applications on SAP BTP and provides a supportive set of APIs, languages, and libraries. For more information about the SAP Cloud Application Programming Model, see [Working with the SAP Cloud Application Programming Model](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/00823f91779d4d42aa29a498e0535cdf.html).
    56  
    57  In this scenario, we want to show how to implement a basic continuous delivery process for developing applications according to this programming model with the help of project "Piper" on Jenkins. This basic scenario can be adapted and enriched according to your specific needs.
    58  
    59  ### Example
    60  
    61  #### Jenkinsfile
    62  
    63  ```groovy
    64  @Library('piper-lib-os') _
    65  
    66  node(){
    67    stage('Prepare')   {
    68        deleteDir()
    69        checkout scm
    70        setupCommonPipelineEnvironment script:this
    71    }
    72  
    73    stage('Build')   {
    74        mtaBuild script:this
    75    }
    76  
    77    stage('Deploy')   {
    78        cloudFoundryDeploy script:this, deployTool:'mtaDeployPlugin'
    79    }
    80  }
    81  ```
    82  
    83  #### Configuration (`.pipeline/config.yml`)
    84  
    85  ```yaml
    86  steps:
    87    mtaBuild:
    88      buildTarget: 'CF'
    89    cloudFoundryDeploy:
    90      cloudFoundry:
    91        credentialsId: 'CF'
    92        apiEndpoint: '<CF Endpoint>'
    93        org: '<CF Organization>'
    94        space: '<CF Space>'
    95  ```
    96  
    97  #### Parameters
    98  
    99  For the detailed description of the relevant parameters, see:
   100  
   101  * [mtaBuild](../steps/mtaBuild.md)
   102  * [cloudFoundryDeploy](../steps/cloudFoundryDeploy.md)