mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
fix: getting config should also work in case there is no project config (#951)
This commit is contained in:
parent
58128be970
commit
a456282d6a
@ -53,9 +53,12 @@ func generateConfig() error {
|
||||
return errors.Wrap(err, "metadata: read failed")
|
||||
}
|
||||
|
||||
customConfig, err := configOptions.openFile(generalConfig.customConfig)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "config: open failed")
|
||||
var customConfig io.ReadCloser
|
||||
if fileExists(generalConfig.customConfig) {
|
||||
customConfig, err = configOptions.openFile(generalConfig.customConfig)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "config: open failed")
|
||||
}
|
||||
}
|
||||
|
||||
defaultConfig, paramFilter, err := defaultsAndFilters(&metadata)
|
||||
@ -118,3 +121,11 @@ func defaultsAndFilters(metadata *config.StepData) ([]io.ReadCloser, config.Step
|
||||
//ToDo: retrieve default values from metadata
|
||||
return nil, metadata.GetParameterFilters(), nil
|
||||
}
|
||||
|
||||
func fileExists(filename string) bool {
|
||||
info, err := os.Stat(filename)
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
return !info.IsDir()
|
||||
}
|
||||
|
@ -81,12 +81,9 @@ func (c *Config) GetStepConfig(flagValues map[string]interface{}, paramJSON stri
|
||||
var stepConfig StepConfig
|
||||
var d PipelineDefaults
|
||||
|
||||
if err := c.ReadConfig(configuration); err != nil {
|
||||
switch err.(type) {
|
||||
case *ParseError:
|
||||
if configuration != nil {
|
||||
if err := c.ReadConfig(configuration); err != nil {
|
||||
return StepConfig{}, errors.Wrap(err, "failed to parse custom pipeline configuration")
|
||||
default:
|
||||
//ignoring unavailability of config file since considered optional
|
||||
}
|
||||
}
|
||||
c.ApplyAliasConfig(parameters, filters, stageName, stepName)
|
||||
|
Loading…
Reference in New Issue
Block a user