【问题标题】:SAP Cloud SDK Jenkins pipeline s4sdk-pipeline.groovy - production deployment step is skippedSAP Cloud SDK Jenkins 管道 s4sdk-pipeline.groovy - 跳过生产部署步骤
【发布时间】:2019-11-07 23:46:21
【问题描述】:

我已经设置了 Jenkins 项目 piper (https://sap.github.io/jenkins-library/)。然后,我设置了一个基本的 SAP Cloud Application Programming 模型应用程序,该应用程序集成了具有默认配置的 SAP Cloud SDK 管道,并取消了“productionDeployment”阶段的注释并完成了 Cloud Foundry 端点/组织/空间等。我已将应用程序提交给主分支在 git 仓库中。

管道成功执行,但正在跳过生产部署步骤。

Pipeline execution results

查看日志时我看到:

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

当我查看脚本 (https://github.com/SAP/cloud-s4-sdk-pipeline/blob/master/s4sdk-pipeline.groovy) 时,我看到了:

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

谁能解释通过 commonPipelineEnvironment.configuration.runStage.PRODUCTION_DEPLOYMENT 检查以执行 stageProductionDeployment 脚本需要什么?

我的 pipeline_config.yml 文件(匿名)是:

###
# 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'

我的 Jenkins 文件没有改变:

#!/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'
}

任何想法我在生产部署中缺少什么以及如何在生产部署脚本中完成此检查?

问候 尼尔

【问题讨论】:

  • 我猜这是因为分支或其检测。您能否告诉我们您正在使用哪种 Jenkins Job(例如 MultiBranch Pipeline)?如果是MultiBranch Pipeline,是master分支的日志输出吗?
  • 尼尔您好,丹尼尔的回答解决了您的问题吗?如果是这样,请为可能遇到此问题的其他社区成员提供答案。谢谢。
  • 你好丹尼尔。 Git repo (master) 中目前只有一个分支,它是 Jenkins 中的一个简单“管道”。
  • 嗨,尼尔,您必须使用作业类型“多分支管道”。见:blogs.sap.com/2017/09/20/continuous-integration-and-delivery

标签: jenkins-pipeline sap-cloud-sdk


【解决方案1】:

管道是为多分支管道构建的,无法在单分支管道作业中正常工作。在多分支管道作业中运行具有单个分支的项目没有问题。为避免混淆,我们在最近的版本中添加了对管道的检查,如此处所述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

亲切的问候

弗洛里安

【讨论】:

  • 嗨弗洛里安感谢您的澄清。我正在使用此文档sap.github.io/jenkins-library/guidedtour,其中提到在 Jenkins 中选择“管道”(不是多分支管道)。也许这也可以更新?
  • 您参考的本文档部分未描述 SAP Cloud SDK 管道。我明白这怎么可能令人困惑。感谢您指出混乱的根源。
  • 也许这个页面 sap.github.io/jenkins-library/scenarios/CAP_Scenario 提到配置 productionDeployment 阶段(就在 Legacy 文档的标题之前)可以更新为提到生产部署只能在多分支管道中工作?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-07
  • 1970-01-01
  • 1970-01-01
  • 2022-11-03
  • 2017-11-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多