github.com/ouraigua/jenkins-library@v0.0.0-20231028010029-fbeaf2f3aa9b/src/com/sap/piper/CfManifestUtils.groovy (about)

     1  package com.sap.piper
     2  
     3  import com.cloudbees.groovy.cps.NonCPS
     4  
     5  class CfManifestUtils {
     6      @NonCPS
     7      static Map transform(Map manifest) {
     8          if (manifest.applications[0].buildpacks) {
     9              manifest['applications'].each { Map application ->
    10                  def buildpacks = application['buildpacks']
    11                  if (buildpacks) {
    12                      if (buildpacks instanceof List) {
    13                          if (buildpacks.size > 1) {
    14                              throw new RuntimeException('More than one Cloud Foundry Buildpack is not supported. Please check your manifest.yaml file.')
    15                          }
    16                          application['buildpack'] = buildpacks[0]
    17                          application.remove('buildpacks')
    18                      } else {
    19                          throw new RuntimeException('"buildpacks" in manifest.yaml is not a list. Please check your manifest.yaml file.')
    20                      }
    21                  }
    22              }
    23          }
    24          return manifest
    25      }
    26  }