1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-11-06 09:09:19 +02:00

Add telemetry for abapEnvironment steps (#3016)

* Remove explicit telemetry from signature

* Set log level

* ATC set error category
This commit is contained in:
Daniel Mieg
2021-08-04 17:31:16 +02:00
committed by GitHub
parent f9e052e4d1
commit 9c76b89fb8
11 changed files with 45 additions and 37 deletions

View File

@@ -43,6 +43,7 @@ func (abaputils *AbapUtils) GetAbapCommunicationArrangementInfo(options AbapEnvi
// Host, User and Password are directly provided -> check for host schema (double https)
match, err := regexp.MatchString(`^(https|HTTPS):\/\/.*`, options.Host)
if err != nil {
log.SetErrorCategory(log.ErrorConfiguration)
return connectionDetails, errors.Wrap(err, "Schema validation for host parameter failed. Check for https.")
}
var hostOdataURL = options.Host + oDataURL
@@ -56,6 +57,7 @@ func (abaputils *AbapUtils) GetAbapCommunicationArrangementInfo(options AbapEnvi
} else {
if options.CfAPIEndpoint == "" || options.CfOrg == "" || options.CfSpace == "" || options.CfServiceInstance == "" || options.CfServiceKeyName == "" {
var err = errors.New("Parameters missing. Please provide EITHER the Host of the ABAP server OR the Cloud Foundry ApiEndpoint, Organization, Space, Service Instance and a corresponding Service Key for the Communication Scenario SAP_COM_0510")
log.SetErrorCategory(log.ErrorConfiguration)
return connectionDetails, err
}
// Url, User and Password should be read from a cf service key
@@ -99,6 +101,7 @@ func ReadServiceKeyAbapEnvironment(options AbapEnvironmentOptions, c command.Exe
// parse
json.Unmarshal([]byte(serviceKeyJSON), &abapServiceKey)
if abapServiceKey == (AbapServiceKey{}) {
log.SetErrorCategory(log.ErrorInfrastructure)
return abapServiceKey, errors.New("Parsing the service key failed. Service key is empty")
}

View File

@@ -22,6 +22,7 @@ func PollEntity(repositoryName string, connectionDetails ConnectionDetailsHTTP,
for {
var resp, err = GetHTTPResponse("GET", connectionDetails, nil, client)
if err != nil {
log.SetErrorCategory(log.ErrorInfrastructure)
err = HandleHTTPError(resp, err, "Could not pull the Repository / Software Component "+repositoryName, connectionDetails)
return "", err
}
@@ -37,6 +38,7 @@ func PollEntity(repositoryName string, connectionDetails ConnectionDetailsHTTP,
if reflect.DeepEqual(PullEntity{}, body) {
log.Entry().WithField("StatusCode", resp.Status).WithField("repositoryName", repositoryName).Error("Could not pull the Repository / Software Component")
log.SetErrorCategory(log.ErrorInfrastructure)
var err = errors.New("Request to ABAP System not successful")
return "", err
}
@@ -45,6 +47,7 @@ func PollEntity(repositoryName string, connectionDetails ConnectionDetailsHTTP,
log.Entry().WithField("StatusCode", resp.Status).Info("Pull Status: " + body.StatusDescription)
if body.Status != "R" {
if body.Status == "E" {
log.SetErrorCategory(log.ErrorUndefined)
PrintLogs(body, true)
} else {
PrintLogs(body, false)
@@ -109,18 +112,22 @@ func PrintLogs(entity PullEntity, errorOnSystem bool) {
func GetRepositories(config *RepositoriesConfig) ([]Repository, error) {
var repositories = make([]Repository, 0)
if reflect.DeepEqual(RepositoriesConfig{}, config) {
log.SetErrorCategory(log.ErrorConfiguration)
return repositories, fmt.Errorf("Failed to read repository configuration: %w", errors.New("Eror in configuration, most likely you have entered empty or wrong configuration values. Please make sure that you have correctly specified them. For more information please read the User documentation"))
}
if config.RepositoryName == "" && config.BranchName == "" && config.Repositories == "" && len(config.RepositoryNames) == 0 {
log.SetErrorCategory(log.ErrorConfiguration)
return repositories, fmt.Errorf("Failed to read repository configuration: %w", errors.New("You have not specified any repository configuration. Please make sure that you have correctly specified it. For more information please read the User documentation"))
}
if config.Repositories != "" {
descriptor, err := ReadAddonDescriptor(config.Repositories)
if err != nil {
log.SetErrorCategory(log.ErrorConfiguration)
return repositories, err
}
err = CheckAddonDescriptorForRepositories(descriptor)
if err != nil {
log.SetErrorCategory(log.ErrorConfiguration)
return repositories, fmt.Errorf("Error in config file %v, %w", config.Repositories, err)
}
repositories = descriptor.Repositories