Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Fix QualityGate failing (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
sadmananik authored Aug 21, 2024
1 parent af2d621 commit a8093f5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private List<String> getCoverityMissingMandatoryParams(Map<String, Object> cover
if (missingMandatoryParams.size() == 1) {
message = missingMandatoryParams.get(0) + " is mandatory parameter for " + jobTypeName + " job type";
} else {
message = String.join(", ", missingMandatoryParams) + " is mandatory parameter for " + jobTypeName
message = String.join(", ", missingMandatoryParams) + " are mandatory parameter for " + jobTypeName
+ " job type";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private List<String> getPolarisMissingMandatoryParams(Map<String, Object> polari
if (missingMandatoryParams.size() == 1) {
message = missingMandatoryParams.get(0) + " is mandatory parameter for " + jobTypeName + " job type";
} else {
message = String.join(", ", missingMandatoryParams) + " is mandatory parameter for " + jobTypeName
message = String.join(", ", missingMandatoryParams) + " are mandatory parameter for " + jobTypeName
+ " job type";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,7 @@ private List<String> getSrmMissingMandatoryParams(Map<String, Object> srmParamet
});

String jobType = Utility.jenkinsJobType(envVars);
if (!jobType.equalsIgnoreCase(ApplicationConstants.MULTIBRANCH_JOB_TYPE_NAME)) {
boolean isProjectNameValid = srmParameters.containsKey(ApplicationConstants.SRM_PROJECT_NAME_KEY)
&& srmParameters.get(ApplicationConstants.SRM_PROJECT_NAME_KEY) != null
&& !srmParameters
.get(ApplicationConstants.SRM_PROJECT_NAME_KEY)
.toString()
.isEmpty();

boolean isProjectIdValid = srmParameters.containsKey(ApplicationConstants.SRM_PROJECT_ID_KEY)
&& srmParameters.get(ApplicationConstants.SRM_PROJECT_ID_KEY) != null
&& !srmParameters
.get(ApplicationConstants.SRM_PROJECT_ID_KEY)
.toString()
.isEmpty();

if (!isProjectNameValid && !isProjectIdValid) {
logger.error("One of " + ApplicationConstants.SRM_PROJECT_NAME_KEY + " or "
+ ApplicationConstants.SRM_PROJECT_ID_KEY + " must be present.");
missingMandatoryParams.add(ApplicationConstants.SRM_PROJECT_ID_KEY);
}
}
validateProjectParams(srmParameters, missingMandatoryParams, jobType);

if (!missingMandatoryParams.isEmpty()) {
String jobTypeName;
Expand All @@ -99,7 +79,7 @@ private List<String> getSrmMissingMandatoryParams(Map<String, Object> srmParamet
if (missingMandatoryParams.size() == 1) {
message = missingMandatoryParams.get(0) + " is mandatory parameter for " + jobTypeName + " job type";
} else {
message = String.join(", ", missingMandatoryParams) + " is mandatory parameter for " + jobTypeName
message = String.join(", ", missingMandatoryParams) + " are mandatory parameter for " + jobTypeName
+ " job type";
}

Expand All @@ -109,6 +89,31 @@ private List<String> getSrmMissingMandatoryParams(Map<String, Object> srmParamet
return missingMandatoryParams;
}

private void validateProjectParams(
Map<String, Object> srmParameters, List<String> missingMandatoryParams, String jobType) {
if (!jobType.equalsIgnoreCase(ApplicationConstants.MULTIBRANCH_JOB_TYPE_NAME)) {
boolean isProjectNameValid = srmParameters.containsKey(ApplicationConstants.SRM_PROJECT_NAME_KEY)
&& srmParameters.get(ApplicationConstants.SRM_PROJECT_NAME_KEY) != null
&& !srmParameters
.get(ApplicationConstants.SRM_PROJECT_NAME_KEY)
.toString()
.isEmpty();

boolean isProjectIdValid = srmParameters.containsKey(ApplicationConstants.SRM_PROJECT_ID_KEY)
&& srmParameters.get(ApplicationConstants.SRM_PROJECT_ID_KEY) != null
&& !srmParameters
.get(ApplicationConstants.SRM_PROJECT_ID_KEY)
.toString()
.isEmpty();

if (!isProjectNameValid && !isProjectIdValid) {
logger.error("One of " + ApplicationConstants.SRM_PROJECT_NAME_KEY + " or "
+ ApplicationConstants.SRM_PROJECT_ID_KEY + " must be present.");
missingMandatoryParams.add(ApplicationConstants.SRM_PROJECT_ID_KEY);
}
}
}

public SRM prepareSrmObjectForBridge(Map<String, Object> srmParameters) {
SRM srm = new SRM();
Branch branch = new Branch();
Expand Down

0 comments on commit a8093f5

Please sign in to comment.