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

     1  # ${docGenStepName}
     2  
     3  ## ${docGenDescription}
     4  
     5  ## Prerequisites
     6  
     7  * This step is for creating a Service Key for an existing Service in Cloud Foundry.
     8  * Cloud Foundry API endpoint, Organization, Space, user and Service Instance are available
     9  * Credentials have been configured in Jenkins with a dedicated Id
    10  * Additionally you can set the optional `serviceKeyConfig` flag to configure the Service Key creation with your respective JSON configuration. The JSON configuration can either be a JSON or the path a dedicated JSON configuration file containing the JSON configuration. If you chose a dedicated config file, it must be stored in a file that must be referenced in the `serviceKeyConfigFile` flag. You must store the file in the same folder as your `Jenkinsfile` that starts the Pipeline in order for the Pipeline to be able to find the file. Most favourable SCM is Git.
    11  
    12  ## ${docGenParameters}
    13  
    14  ## ${docGenConfiguration}
    15  
    16  ## ${docJenkinsPluginDependencies}
    17  
    18  ## Examples
    19  
    20  The following examples will create a Service Key named "myServiceKey" for the Service Instance "myServiceInstance" in the provided Cloud Foundry Organization and Space. For the Service Key creation in these example, the serviceKeyConfig parameter is used. It will show the different ways of passing the JSON configuration, either via a string or the path to a file containing the JSON configuration.
    21  If you dont want to use a special configuration simply remove the parameter since it is optional.
    22  
    23  ### Create Service Key with JSON config file in Jenkinsfile
    24  
    25  This example covers the parameters for a Jenkinsfile when using the cloudFoundryCreateServiceKey step. It uses a `serviceKeaConfig.json` file with valid JSON objects for creating a Cloud Foundry Service Key.
    26  
    27  ```groovy
    28  cloudFoundryCreateServiceKey(
    29    cfApiEndpoint: 'https://test.server.com',
    30    cfCredentialsId: 'cfCredentialsId',
    31    cfOrg: 'cfOrg',
    32    cfSpace: 'cfSpace',
    33    cfServiceInstance: 'myServiceInstance',
    34    cfServiceKeyName: 'myServiceKey',
    35    cfServiceKeyConfig: 'serviceKeyConfig.json',
    36    script: this,
    37  )
    38  ```
    39  
    40  The JSON config file, e.g. `serviceKeyConfig.json` can look like this:
    41  
    42  ```json
    43  {
    44    "example":"value",
    45    "example":"value"
    46  }
    47  ```
    48  
    49  ### Create Service Key with JSON string in Jenkinsfile
    50  
    51  The following example covers the creation of a Cloud Foundry Service Key in a Jenkinsfile with using a JSON string as a config for the Service Key creation. If you use a Jenkinsfile for passing the parameter values you need to escape the double quotes in the JSON config string.
    52  
    53  ```groovy
    54  cloudFoundryCreateServiceKey(
    55    cfApiEndpoint: 'https://test.server.com',
    56    cfCredentialsId: 'cfCredentialsId',
    57    cfOrg: 'cfOrg',
    58    cfSpace: 'cfSpace',
    59    cfServiceInstance: 'myServiceInstance',
    60    cfServiceKeyName: 'myServiceKey',
    61    cfServiceKeyConfig: '{\"example\":\"value\",\"example\":\"value\"}',
    62    script: this,
    63  )
    64  ```
    65  
    66  ### Create Service Key with JSON string as parameter in .pipeline/config.yml file
    67  
    68  If you chose to provide a `config.yml` file you can provide the parameters including the values in this file. You only need to set the script parameter when calling the step:
    69  
    70  ```groovy
    71  cloudFoundryCreateServiceKey(
    72    script: this,
    73  )
    74  ```
    75  
    76  The `.pipeline/config.yml` has to contain the following parameters accordingly:
    77  
    78  ```yaml
    79  steps:
    80      cloudFoundryCreateServiceKey:
    81          cfApiEndpoint: 'https://test.server.com'
    82          cfOrg: 'testOrg'
    83          cfSpace: 'testSpace'
    84          cfServiceInstance: 'testInstance'
    85          cfServiceKeyName: 'myServiceKey'
    86          cfServiceKeyConfig: '{"example":"value","example":"value"}'
    87          cfCredentialsId: 'cfCredentialsId'
    88  ```
    89  
    90  When using a `.pipeline/config.yml` file you don't need to escape the double quotes in the JSON config string.
    91  You can also pass the path to a JSON config file in the `cfServiceKeyConfig` parameter. Example: `cfServiceKeyConfig: 'serviceKeyconfig.json'`