1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-06-17 00:07:42 +02:00

InfluxDB support (#52)

* adding step for writing metrics to InfluxDB including dependencies
* added documentation
* incorporated PR feedback
This commit is contained in:
Oliver Nocon
2018-01-24 09:55:38 +01:00
committed by GitHub
parent b9eedda38e
commit 749aa5e7ed
17 changed files with 751 additions and 14 deletions

View File

@ -1,7 +1,7 @@
# ConfigurationMerger
## Description
A helper script that can merge the configurations from multiple sources.
A helper script that can merge the configurations from multiple sources.
## Static Method Details
@ -10,8 +10,8 @@ A helper script that can merge the configurations from multiple sources.
#### Description
A step is usually configured by default values, configuration values from the configuration file and the parameters.
The methods can merge these sources.
Default values are overwritten by configuration file values.
The method can merge these sources.
Default values are overwritten by configuration file values.
These are overwritten by parameters.
#### Parameters
@ -25,9 +25,9 @@ These are overwritten by parameters.
| `defaults` | yes | Map |
* `parameters` Parameters map given to the step
* `parameterKeys` List of parameter names (keys) that should be considered while merging.
* `parameterKeys` List of parameter names (keys) that should be considered while merging.
* `configurationMap` Configuration map loaded from the configuration file.
* `configurationKeys` List of configuration keys that should be considered while merging.
* `configurationKeys` List of configuration keys that should be considered while merging.
* `defaults` Map of default values, e.g. loaded from the default value configuration file.
#### Side effects
@ -62,3 +62,62 @@ List stepConfigurationKeys = [
Map configuration = ConfigurationMerger.merge(parameters, parameterKeys, stepConfiguration, stepConfigurationKeys, stepDefaults)
```
### mergeWithPipelineData
#### Description
A step is usually configured by default values, configuration values from the configuration file and the parameters.
In certain cases also information previously generated in the pipeline should be mixed in, like for example an artifactVersion created earlier.
The method can merge these sources.
Default values are overwritten by configuration file values.
Those are overwritten by information previously generated in the pipeline (e.g. stored in [commonPipelineEnvironment](../steps/commonPipelineEnvironment.md)).
These are overwritten by parameters passed directly to the step.
#### Parameters
| parameter | mandatory | Class |
| -------------------|-----------|-----------------------------------|
| `parameters` | yes | Map |
| `parameterKeys` | yes | List |
| `pipelineDataMap` | yes | Map |
| `configurationMap` | yes | Map |
| `configurationKeys`| yes | List |
| `defaults` | yes | Map |
* `parameters` Parameters map given to the step
* `parameterKeys` List of parameter names (keys) that should be considered while merging.
* `configurationMap` Configuration map loaded from the configuration file.
* `pipelineDataMap` Values available to the step during pipeline run.
* `configurationKeys` List of configuration keys that should be considered while merging.
* `defaults` Map of default values, e.g. loaded from the default value configuration file.
#### Side effects
none
#### Example
```groovy
def stepName = 'influxWriteData'
prepareDefaultValues script: script
final Map stepDefaults = ConfigurationLoader.defaultStepConfiguration(script, stepName)
final Map stepConfiguration = ConfigurationLoader.stepConfiguration(script, stepName)
final Map generalConfiguration = ConfigurationLoader.generalConfiguration(script)
List parameterKeys = [
'artifactVersion',
'influxServer',
'influxPrefix'
]
Map pipelineDataMap = [
artifactVersion: commonPipelineEnvironment.getArtifactVersion()
]
List stepConfigurationKeys = [
'influxServer',
'influxPrefix'
]
Map configuration = ConfigurationMerger.mergeWithPipelineData(parameters, parameterKeys, pipelineDataMap, stepConfiguration, stepConfigurationKeys, stepDefaults)
```

View File

@ -0,0 +1,30 @@
# JsonUtils
## Description
Provides json related utility functions.
## Constructors
### JsonUtils()
Default no-argument constructor. Instances of the Utils class does not hold any instance specific state.
#### Example
```groovy
new JsonUtils()
```
## Method Details
### getPrettyJsonString(object)
#### Description
Creates a pretty-printed json string.
#### Parameters
* `object` - A object (e.g. Map or List).
#### Return value
A pretty printed `String`.
#### Side effects
none

View File

@ -24,7 +24,7 @@ Retrieves the parameter value for parameter `paramName` from parameter map `map`
#### Parameters
* `map` - A map containing configuration parameters.
* `paramName` - The key of the parameter which should be looked up.
* `defaultValue` - The value which is returned in case there is no parameter with key `paramName` contained in `map`.
* optional: `defaultValue` - The value which is returned in case there is no parameter with key `paramName` contained in `map`. If it is not provided the default is `null`.
#### Return value
The value to the parameter to be retrieved, or the default value if the former is `null`, either since there is no such key or the key is associated with value `null`. In case the parameter is not defined or the value for that parameter is `null`and there is no default value an exception is thrown.