1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

Extend api

This commit is contained in:
Florian Wilhelm 2019-01-08 17:35:53 +01:00
parent 05e4824268
commit 7f1713148f
7 changed files with 13 additions and 10 deletions

View File

@ -50,11 +50,11 @@ provided pipeline library.
## API ## API
All steps are intended to be used by Pipelines. All the classes / groovy-scripts All steps (`vars` directory) are intended to be used by Pipelines and are considered API.
contained in the `src` folder are by default not part of the API and are subjected to change All the classes / groovy-scripts contained in the `src` folder are by default not part of
without prior notice. Types and methods annotated with `@API` are considered to be API, used e.g. the API and are subjected to change without prior notice. Types and methods annotated with
from other shared libraries. Changes to those methods/types needs to be announced, disussed and `@API` are considered to be API, used e.g. from other shared libraries. Changes to those
agreed. methods/types needs to be announced, discussed and agreed.
# Requirements # Requirements

View File

@ -2,6 +2,7 @@ package com.sap.piper
import com.cloudbees.groovy.cps.NonCPS import com.cloudbees.groovy.cps.NonCPS
@API
class ConfigurationHelper implements Serializable { class ConfigurationHelper implements Serializable {
static ConfigurationHelper newInstance(Script step, Map config = [:]) { static ConfigurationHelper newInstance(Script step, Map config = [:]) {
@ -31,19 +32,16 @@ class ConfigurationHelper implements Serializable {
return this return this
} }
@API
ConfigurationHelper mixinGeneralConfig(commonPipelineEnvironment, Set filter = null, Map compatibleParameters = [:]){ ConfigurationHelper mixinGeneralConfig(commonPipelineEnvironment, Set filter = null, Map compatibleParameters = [:]){
Map stepConfiguration = ConfigurationLoader.generalConfiguration([commonPipelineEnvironment: commonPipelineEnvironment]) Map stepConfiguration = ConfigurationLoader.generalConfiguration([commonPipelineEnvironment: commonPipelineEnvironment])
return mixin(stepConfiguration, filter, compatibleParameters) return mixin(stepConfiguration, filter, compatibleParameters)
} }
@API
ConfigurationHelper mixinStageConfig(commonPipelineEnvironment, stageName, Set filter = null, Map compatibleParameters = [:]){ ConfigurationHelper mixinStageConfig(commonPipelineEnvironment, stageName, Set filter = null, Map compatibleParameters = [:]){
Map stageConfiguration = ConfigurationLoader.stageConfiguration([commonPipelineEnvironment: commonPipelineEnvironment], stageName) Map stageConfiguration = ConfigurationLoader.stageConfiguration([commonPipelineEnvironment: commonPipelineEnvironment], stageName)
return mixin(stageConfiguration, filter, compatibleParameters) return mixin(stageConfiguration, filter, compatibleParameters)
} }
@API
ConfigurationHelper mixinStepConfig(commonPipelineEnvironment, Set filter = null, Map compatibleParameters = [:]){ ConfigurationHelper mixinStepConfig(commonPipelineEnvironment, Set filter = null, Map compatibleParameters = [:]){
Map stepConfiguration = ConfigurationLoader.stepConfiguration([commonPipelineEnvironment: commonPipelineEnvironment], name) Map stepConfiguration = ConfigurationLoader.stepConfiguration([commonPipelineEnvironment: commonPipelineEnvironment], name)
return mixin(stepConfiguration, filter, compatibleParameters) return mixin(stepConfiguration, filter, compatibleParameters)
@ -103,7 +101,6 @@ class ConfigurationHelper implements Serializable {
return this return this
} }
@API
@NonCPS // required because we have a closure in the @NonCPS // required because we have a closure in the
// method body that cannot be CPS transformed // method body that cannot be CPS transformed
Map use(){ Map use(){
@ -152,7 +149,6 @@ class ConfigurationHelper implements Serializable {
} }
} }
@API
ConfigurationHelper withMandatoryProperty(key, errorMessage = null, condition = null){ ConfigurationHelper withMandatoryProperty(key, errorMessage = null, condition = null){
if(condition){ if(condition){
if(condition(this.config)) if(condition(this.config))

View File

@ -2,6 +2,7 @@ package com.sap.piper
import com.cloudbees.groovy.cps.NonCPS import com.cloudbees.groovy.cps.NonCPS
@API
class ConfigurationLoader implements Serializable { class ConfigurationLoader implements Serializable {
@NonCPS @NonCPS
static Map stepConfiguration(script, String stepName) { static Map stepConfiguration(script, String stepName) {

View File

@ -2,6 +2,7 @@ package com.sap.piper
import com.cloudbees.groovy.cps.NonCPS import com.cloudbees.groovy.cps.NonCPS
@API
class ConfigurationMerger { class ConfigurationMerger {
@NonCPS @NonCPS
static Map merge(Map configs, Set configKeys, Map defaults) { static Map merge(Map configs, Set configKeys, Map defaults) {

View File

@ -2,6 +2,7 @@ package com.sap.piper
import com.cloudbees.groovy.cps.NonCPS import com.cloudbees.groovy.cps.NonCPS
@API
class DefaultValueCache implements Serializable { class DefaultValueCache implements Serializable {
private static DefaultValueCache instance private static DefaultValueCache instance

View File

@ -4,6 +4,7 @@ import com.cloudbees.groovy.cps.NonCPS
import jenkins.model.Jenkins import jenkins.model.Jenkins
import org.jenkinsci.plugins.workflow.steps.MissingContextVariableException import org.jenkinsci.plugins.workflow.steps.MissingContextVariableException
@API
@NonCPS @NonCPS
static def isPluginActive(pluginId) { static def isPluginActive(pluginId) {
return Jenkins.instance.pluginManager.plugins.find { p -> p.isActive() && p.getShortName() == pluginId } return Jenkins.instance.pluginManager.plugins.find { p -> p.isActive() && p.getShortName() == pluginId }

View File

@ -1,5 +1,8 @@
package com.sap.piper.k8s package com.sap.piper.k8s
import com.sap.piper.API
@API
@Singleton @Singleton
class ContainerMap { class ContainerMap {
private Map containerMap = null private Map containerMap = null