1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-16 11:09:33 +02:00
sap-jenkins-library/documentation/docs/scenarios/CAP_Scenario.md
Daniel Kurzynski 0afc5dd1bd
Update CAP Scenario (#2438)
* Update CAP Scenario

* Next step
2020-12-02 16:43:28 +01:00

4.7 KiB

Build and Deploy SAP Cloud Application Programming Model Applications

In this scenario, we will setup a CI/CD Pipeline for a SAP Cloud Application Programming Model (CAP) project.

Prerequisites

  • You have the SAP Cloud Application Programming Model command line tool (cds-dk) installed: See Get Started.
  • You have setup a suitable Jenkins instance as described in Guided Tour

Context

The Application Programming Model for SAP Cloud Platform is an end-to-end best practice guide for developing applications on SAP Cloud Platform and provides a supportive set of APIs, languages, and libraries. For more information about the SAP Cloud Application Programming Model, visit its documentation.

Getting started

To get started, generate a project using the SAP Cloud Application Programming Model command line tools:

cds init bookshop --add java,mta,samples,hana

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:

cd bookshop
cds add pipeline

This will generate a project which already includes a Jenkinsfile, and a .pipeline/config.yml file.

Now, you'll need to push the code to a git repository. This is required because the pipeline gets your code via git. This might be GitHub, or any other cloud or on-premise git solution you have in your company.

Afterwards you can connect your Jenkins instance to your git repository and let it build the project.

Legacy documentation

If your project is not based on the SAP Cloud Platform Business Application WebIDE template, you could either migrate your code to comply with the structure which is described here, or you can use a self built pipeline, as described in this section.

Prerequisites

Context

The Application Programming Model for SAP Cloud Platform is an end-to-end best practice guide for developing applications on SAP Cloud Platform 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.

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.

Example

Jenkinsfile

@Library('piper-lib-os') _

node(){
  stage('Prepare')   {
      deleteDir()
      checkout scm
      setupCommonPipelineEnvironment script:this
  }

  stage('Build')   {
      mtaBuild script:this
  }

  stage('Deploy')   {
      cloudFoundryDeploy script:this, deployTool:'mtaDeployPlugin'
  }
}

Configuration (.pipeline/config.yml)

steps:
  mtaBuild:
    buildTarget: 'CF'
  cloudFoundryDeploy:
    cloudFoundry:
      credentialsId: 'CF'
      apiEndpoint: '<CF Endpoint>'
      org: '<CF Organization>'
      space: '<CF Space>'

Parameters

For the detailed description of the relevant parameters, see: