github.com/xgoffin/jenkins-library@v1.154.0/documentation/docs/steps/cfManifestSubstituteVariables.md (about)

     1  # ${docGenStepName}
     2  
     3  ## ${docGenDescription}
     4  
     5  ## ${docGenParameters}
     6  
     7  ## ${docGenConfiguration}
     8  
     9  ## ${docJenkinsPluginDependencies}
    10  
    11  ## Side effects
    12  
    13  Unless configured otherwise, this step will *replace* the input `manifest.yml` with a version that has all variable references replaced. This alters the source tree in your Jenkins workspace.
    14  If you prefer to generate a separate output file, use the step's `outputManifestFile` parameter. Keep in mind, however, that your Cloud Foundry deployment step should then also reference this output file - otherwise CF deployment will fail with unresolved variable reference errors.
    15  
    16  ## Exceptions
    17  
    18  * `org.yaml.snakeyaml.scanner.ScannerException` - in case any of the loaded input files contains malformed Yaml and cannot be parsed.
    19  
    20  * `hudson.AbortException` - in case of internal errors and when not all variables could be replaced due to missing replacement values.
    21  
    22  ## Example
    23  
    24  Usage of pipeline step:
    25  
    26  ```groovy
    27  cfManifestSubstituteVariables (
    28    script: this,
    29    manifestFile: "path/to/manifest.yml",                      //optional, default: manifest.yml
    30    manifestVariablesFiles: ["path/to/manifest-variables.yml"] //optional, default: ['manifest-variables.yml']
    31    manifestVariables: [[key : value], [key : value]]          //optional, default: []
    32  )
    33  ```
    34  
    35  For example, you can refer to the parameters using relative paths (similar to `cf push --vars-file`):
    36  
    37  ```groovy
    38  cfManifestSubstituteVariables (
    39    script: this,
    40    manifestFile: "manifest.yml",
    41    manifestVariablesFiles: ["manifest-variables.yml"]
    42  )
    43  ```
    44  
    45  Furthermore, you can also specify variables and their values directly (similar to `cf push --var`):
    46  
    47  ```groovy
    48  cfManifestSubstituteVariables (
    49    script: this,
    50    manifestFile: "manifest.yml",
    51    manifestVariablesFiles: ["manifest-variables.yml"],
    52    manifestVariables: [[key1 : value1], [key2 : value2]]
    53  )
    54  ```
    55  
    56  If you are using the Cloud Foundry [Create-Service-Push](https://github.com/dawu415/CF-CLI-Create-Service-Push-Plugin) CLI plugin you will most likely also have a `services-manifest.yml` file.
    57  Also in this file you can specify variable references, that can be resolved from the same variables file, e.g. like this:
    58  
    59  ```groovy
    60  // resolve variables in manifest.yml
    61  cfManifestSubstituteVariables (
    62    script: this,
    63    manifestFile: "manifest.yml",
    64    manifestVariablesFiles: ["manifest-variables.yml"]
    65  )
    66  
    67  // resolve variables in services-manifest.yml from same file.
    68  cfManifestSubstituteVariables (
    69    script: this,
    70    manifestFile: "services-manifest.yml",
    71    manifestVariablesFiles: ["manifest-variables.yml"]
    72  )
    73  ```