Skip to content

Commit

Permalink
Add parameter checks
Browse files Browse the repository at this point in the history
Signed-off-by: Zelin Hao <[email protected]>
  • Loading branch information
zelinh committed Aug 16, 2023
1 parent d8ac8a6 commit 889a941
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions vars/createUploadTestReportManifest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
def call(Map args = [:]) {
lib = library(identifier: 'jenkins@main', retriever: legacySCM(scm))

if (!parameterCheck(args.testManifest, args.buildManifest, args.testRunID, args.testType)) return

def testRunID = args.testRunID;
def testType = args.testType;

Expand Down Expand Up @@ -98,3 +100,23 @@ String generateUploadPath(testManifest, buildManifest, dashboardsBuildManifest,
}

boolean isNullOrEmpty(String str) { return (str == null || str.allWhitespace || str.isEmpty()) }

boolean parameterCheck(String testManifest, String buildManifest, String testRunID, String testType) {
if (isNullOrEmpty(testManifest)) {
echo "Required argument ${testManifest} is null or empty. Skip running report workflow."
return false
}
if (isNullOrEmpty(buildManifest)) {
echo "Required argument ${buildManifest} is null or empty. Skip running report workflow."
return false
}
if (isNullOrEmpty(testRunID)) {
echo "Required argument ${testRunID} is null or empty. Skip running report workflow."
return false
}
if (isNullOrEmpty(testType)) {
echo "Required argument ${testType} is null or empty. Skip running report workflow."
return false
}
return true
}

0 comments on commit 889a941

Please sign in to comment.