2
votes

I have setup Jenkins project piper (https://sap.github.io/jenkins-library/). I have then setup a basic SAP Cloud Application Programming model app with integration for the SAP Cloud SDK pipeline with default configuration and uncommented the 'productionDeployment' stage and completed cloud foundry endpoints/orgs/spaces etc. I have committed the applicatino to the master branch in the git repo.

The pipeline executes successfully but is skipping the production deployment step.

Pipeline execution results

When checking the logs I see:

[Pipeline] // stageenter code here
[Pipeline] stage
[Pipeline] { (Production Deployment)
Stage "Production Deployment" skipped due to when conditional

When I look at the script (https://github.com/SAP/cloud-s4-sdk-pipeline/blob/master/s4sdk-pipeline.groovy) I see:

        stage('Production Deployment') {
        *when { expression { commonPipelineEnvironment.configuration.runStage.PRODUCTION_DEPLOYMENT }* }
        //milestone 80 is set in stageProductionDeployment
        steps { stageProductionDeployment script: this }
    }

Can anyone explain what is required to pass the commonPipelineEnvironment.configuration.runStage.PRODUCTION_DEPLOYMENT check in order to execute the stageProductionDeployment script?

My pipeline_config.yml file (anonymized) is:

###
# This file configures the SAP Cloud SDK Continuous Delivery pipeline of your project.
# For a reference of the configuration concept and available options, please have a look into its documentation.
#
# The documentation for the most recent pipeline version can always be found at:
#    https://github.com/SAP/cloud-s4-sdk-pipeline/blob/master/configuration.md
# If you are using a fixed version of the pipeline, please make sure to view the corresponding version from the tag
# list of GitHub (e.g. "v15" when you configured pipelineVersion = "v15" in the Jenkinsfile).
#
# For general information on how to get started with Continuous Delivery, visit:
#    https://blogs.sap.com/2017/09/20/continuous-integration-and-delivery
#
# We aim to keep the pipeline configuration as stable as possible. However, major changes might also imply breaking
# changes in the configuration. Before doing an update, please check the the release notes of all intermediate releases
# and adapt this file if necessary.
#
# This is a YAML-file. YAML is a indentation-sensitive file format. Please make sure to properly indent changes to it.
###



### General project setup
general:
  productiveBranch: 'master'


### Step-specific configuration
steps:
  setupCommonPipelineEnvironment:
    collectTelemetryData: true

  cloudFoundryDeploy:
    dockerImage: 'ppiper/cf-cli'
    smokeTestStatusCode: '200'
    cloudFoundry:
      org: 'XXXXXX'
      space: 'XXXXXX'
      appName: 'MTBookshopNode'
      manifest: 'mta.yaml'
      credentialsId: 'CF_CREDENTIALSID'
      apiEndpoint: 'https://api.cf.XX10.hana.ondemand.com'

### Stage-specific configuration
stages:

  # This exclude is required for the example project to be successful in the pipeline
  # Remove it when you have added your first test
  s4SdkQualityChecks:
    jacocoExcludes:
      - '**/OrdersService.class'

#  integrationTests:
#    credentials:
#      - alias: 'mySystemAlias'
#        credentialId: 'mySystemCredentialsId'

#  s4SdkQualityChecks:
#    nonErpDestinations:
#      - 'myCustomDestination'

  productionDeployment:
    cfTargets:
      - org: 'XXXXXX'
        space: 'XXXXXX'
        apiEndpoint: 'https://api.cf.XX10.hana.ondemand.com'
        appName: 'myAppName'
        manifest: 'mta.yaml'
        credentialsId: 'CF_CREDENTIALSID'

My Jenkins file is unchanged:

#!/usr/bin/env groovy

/*
 * This file bootstraps the codified Continuous Delivery pipeline for extensions of SAP solutions, such as SAP S/4HANA.
 * The pipeline helps you to deliver software changes quickly and in a reliable manner.
 * A suitable Jenkins instance is required to run the pipeline.
 * The Jenkins can easily be bootstraped using the life-cycle script located inside the 'cx-server' directory.
 *
 * More information on getting started with Continuous Delivery can be found in the following places:
 *   - GitHub repository: https://github.com/SAP/cloud-s4-sdk-pipeline
 *   - Blog Post: https://blogs.sap.com/2017/09/20/continuous-integration-and-delivery
 */

/*
 * Set pipelineVersion to a fixed released version (e.g. "v15") when running in a productive environment.
 * To find out about available versions and release notes, visit: https://github.com/SAP/cloud-s4-sdk-pipeline/releases
 */
String pipelineVersion = "master"

node {
    deleteDir()
    sh "git clone --depth 1 https://github.com/SAP/cloud-s4-sdk-pipeline.git -b ${pipelineVersion} pipelines"
    load './pipelines/s4sdk-pipeline.groovy'
}

Any ideas what I am missing for a production deployment and how I get through this check in the script for production deployment?

Regards Neil

1
My guess it is because of the branch or its detection. Could you please tell us which kind of Jenkins Job (e.g., MultiBranch Pipeline) you are using? If MultiBranch Pipeline, is the log output from the master branch?Daniel Kurzynski
Hello Neil, did Daniel's answer resolve your issue? If so, kindly provide an answer for other community members who might come across this issue. Thanks.Florian Wilhelm
Hi Daniel. There is only one branch at the moment in the Git repo (master) and its a simple 'pipeline' in Jenkins.Neil
Hi Neil, you have to use the job type "multibranch pipeline". See: blogs.sap.com/2017/09/20/continuous-integration-and-deliveryBenjamin

1 Answers

1
votes

the pipeline was built for multi-branch pipelines and will not work correctly in a single-branch pipeline job. There is no problem with running a project that has a single branch in a multi-branch pipeline job. To avoid confusion, we added a check to the pipeline in a recent version as documented here https://blogs.sap.com/2019/11/21/new-versions-of-sap-cloud-sdk-3.8.0-for-java-1.13.1-for-javascript-and-v26-of-continuous-delivery-toolkit/#cd-toolkit

Kind regards

Florian