EDUCAÇÃO E TECNOLOGIA

Working with Integration Suite Piper commands

SAP implements tooling for continuous delivery in opensource project “Piper“. The goal of project “Piper” is to substantially ease setting up continuous delivery in your project using SAP technologies.

For more information about project “Piper” and the other CI and CD offerings by SAP, see Overview of SAP Offerings for CI and CD.

Configuring project piper in your Jenkins server is explained in this blog.

SAP Integration Suite has contributed not only many Jenkins pipelines, but also many piper library steps, which helps you to create your own CI/CD pipeline, automating various tasks.

For example, in the case of  SAP Integration Suite capability “Cloud Integration”, we can automate below scenario

  1. Update the integration flow design time configuration parameter.
  2. Deploy an integration flow.
  3. Get the service endpoint of the deployed integration flow.
  4. Invoke the service endpoint with the HTTP request.
  5. Get message processing log (MPL) status of the integration flow.
  6. If the MPL status is completed in previous step, download integration flow artifact from design time.
  7. Store integration flow artifact in the GitHub repository.

Let’s understand all the Piper commands provided for SAP Integration Suite capabilities, mainly Cloud Integration and API Management.

SAP Cloud Integration Piper Steps

Piper Step Name Description Documentation  Link Pipeline  Example
integrationArtifactDeploy
Deploy an integration flow in to the SAP Cloud Integration runtime
Link
Link
integrationArtifactDownload
Download integration flow runtime artefact
Link
Link
integrationArtifactGetMplStatus
Get the MPL status of an integration flow
Link
Link
integrationArtifactGetServiceEndpoint
Get an deployed integration flow service endpoint
Link
Link
integrationArtifactResource
Add, Delete or Update an resource file of integration flow design time artifact
Link
Link
integrationArtifactUnDeploy
Undeploy a integration flow
Link
Link
integrationArtifactUpdateConfiguration
Update integration flow configuration parameter
Link
Link
integrationArtifactUpload
Upload or Update an integration flow design time artifact
Link
Link

SAP API Management piper steps

Piper Step Name Description Documentation  Link Pipeline  Example
apiProxyDownload
Download a specific API Proxy from the API Portal
Link
Link
apiKeyValueMapDownload
Download a specific Key Value Map from the API Portal
Link
Link
apiProxyUpload
Upload an api proxy artifact in to the API Portal
Link
Link

Going forward, more piper steps would be contributed for both Cloud Integration and API Management.

Now let’s take an example of consuming Cloud Integration piper command “integrationArtifactDeploy” in the Jenkins server.

This involves below steps:

  1. Creating Jenkins pipeline project in GitHub which consumes cloud integration piper command
  2. Configure Cloud Integration API service key in the Jenkins server as security credentials
  3. Configure the piper library in the Global pipeline libraries
  4. Creating new pipeline project in Jenkins based on pipeline script from SCM approach.
  5. Running pipeline project and verifying results

Creating Jenkins pipeline project in GitHub which consumes Cloud Integration piper command

Let’s consume integrationArtifactDeploy piper command which is responsible for deploying an integration flow in to the Cloud Integration runtime.

First step is to create GitHub repository as shown below

Repository has directory called .pipeline and file jenkinsfile. Jenkins file has the groovy script code, which has logic to invoke the integrationArtifactDeploy piper command

Here “integrationArtifactDeploy script: this” line executes the cloud integration piper command

.pipeline has the config.yaml file which provide input arguments for the integrationArtifactDeploy piper command

Here we pass the integration flow ID which has to be deployed and the API service key details which is configured in the Jenkins system as security credential.

Configure Cloud integration API service key in the Jenkins server as security credentials

API service key need to be configured as Jenkins credentials so that all pipeline projects can use it.

Select the Manage Jenkins configuration option in the Jenkins server home page.

 

Select the Manage Credentials option

Select the Global credentials

Copy the service key JSON text from the SAP BTP account cockpit, this can be found in below location.

SAP BTP Cockpit Subaccount home page -> instances and subscriptions -> instance name (API plan)

->Service keys ( view and copy the json text)

Create new credentials of type secret text under add credentials option, paste the service key text under secret text input box and save it.

The same ID used here need to be passed as input for cpiApiServiceKeyCredentialsId configuration parameter in the config.yml file as shown below

Configure the piper library in the Global pipeline libraries

Provide the piper library runtime configuration in the Jenkins configuration -> Global pipeline libraries section.

Creating new pipeline project in Jenkins based on pipeline script from SCM approach.

Select new Item -> pipeline project and provide the project name

Configure the repository URL, branch to pull and script file name as shown below

Click on save/apply to save the project. This step will create Jenkins pipeline project to pull the SCM repository configured in the GitHub and execute the Jenkins file which has logic to execute the SAP cloud integration piper command.

Running pipeline project and verifying results

This step involves build and running the Jenkins pipeline project and verify the SAP cloud integration piper command execution results.

Click on build now and see the latest build results

If you select the specific build and check the console output, you can validate weather piper command successfully executed or not!

You can combine these piper commands and build a complex scenario, where you can manage the end to end lifecycle of an integration flow artefact for CI/CD, starting from configure to deploy, check execution status and store in git etc.

If you want to build your own custom piper command for Integration Suite, you can contribute to opensource SAP Project Piper (https://www.project-piper.io/) and follow the developer guide for building your own custom shared library steps.

Below is the example hello World piper command sample, which you can refer to build it in your own forked piper GitHub repository from piper master repository ( i.e. https://github.com/SAP/jenkins-library)  and test in Jenkins server.

Hello world example step development commits, which show the workflow: https://github.com/marcusholl/jenkins-library/commits/helloWorld

Pipeline to build and run the code in a Jenkins: https://github.com/marcusholl/helloWorld/blob/main/Jenkinsfile#L10

Example of a groovy wrapper with username, Password credentials: https://github.com/SAP/jenkins-library/blob/master/vars/cloudFoundryCreateSpace.groovy