Skip to content

Commit

Permalink
Jenkins Library update for Gradle Check Publish Optimization (#427)
Browse files Browse the repository at this point in the history
Signed-off-by: Prudhvi Godithi <[email protected]>
(cherry picked from commit 068c469)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed May 22, 2024
1 parent 25bf8a4 commit 9a3bc30
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jacocoTestReport {
}
}

String version = '6.4.6'
String version = '6.4.7'

task updateVersion {
doLast {
Expand Down
16 changes: 10 additions & 6 deletions vars/publishGradleCheckTestResults.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ void call(Map args = [:]) {
def buildDuration = currentBuild.duration
def buildResult = currentBuild.result
def buildStartTime = currentBuild.startTimeInMillis
def prString = args.prNumber.toString()
def prNumber = args.prNumber.toString()
def invokeType = args.invokeType.toString()
def prDescription = args.prDescription.toString()
def prOwner = args.prOwner.toString()
def prTitle = args.prTitle.toString()
def gitReference = args.gitReference.toString()
def currentDate = new Date()
def formattedDate = new SimpleDateFormat("MM-yyyy").format(currentDate)

def indexName = "gradle-check-${formattedDate}"

def test_docs = getFailedTestRecords(buildNumber, prString, invokeType, prDescription, buildResult, buildDuration, buildStartTime)
def test_docs = getFailedTestRecords(buildNumber, prNumber, invokeType, prOwner, prTitle, gitReference, buildResult, buildDuration, buildStartTime)

if (test_docs) {
for (doc in test_docs) {
Expand All @@ -50,7 +52,7 @@ void call(Map args = [:]) {
}
}

List<Map<String, String>> getFailedTestRecords(buildNumber, prString, invokeType, prDescription, buildResult, buildDuration, buildStartTime) {
List<Map<String, String>> getFailedTestRecords(buildNumber, prNumber, invokeType, prOwner, prTitle, gitReference, buildResult, buildDuration, buildStartTime) {
def testResults = []
AbstractTestResultAction testResultAction = currentBuild.rawBuild.getAction(AbstractTestResultAction.class)
if (testResultAction != null) {
Expand All @@ -62,7 +64,7 @@ List<Map<String, String>> getFailedTestRecords(buildNumber, prString, invokeType

if (failedTests){
for (test in failedTests) {
def failDocument = ['build_number': buildNumber, 'pull_request': prString, 'invoke_type': invokeType, 'pr_description': prDescription, 'test_class': test.getParent().getName(), 'test_name': test.fullName, 'test_status': 'FAILED', 'build_result': buildResult, 'test_fail_count': testsFailed, 'test_skipped_count': testsSkipped, 'test_passed_count': testsPassed, 'build_duration': buildDuration, 'build_start_time': buildStartTime]
def failDocument = ['build_number': buildNumber, 'pull_request': prNumber, 'pull_request_owner': prOwner , 'invoke_type': invokeType, 'pull_request_title': prTitle, 'git_reference': gitReference, 'test_class': test.getParent().getName(), 'test_name': test.fullName, 'test_status': 'FAILED', 'build_result': buildResult, 'test_fail_count': testsFailed, 'test_skipped_count': testsSkipped, 'test_passed_count': testsPassed, 'build_duration': buildDuration, 'build_start_time': buildStartTime]
testResults.add(failDocument)
}
} else {
Expand Down Expand Up @@ -94,8 +96,10 @@ void indexFailedTestData() {
"properties": {
"build_number": { "type": "integer" },
"pull_request": { "type": "keyword" },
"pull_request_owner": { "type": "keyword" },
"invoke_type": { "type": "keyword" },
"pr_description": { "type": "text" },
"pull_request_title": { "type": "text" },
"git_reference": { "type": "text" },
"test_class": { "type": "keyword" },
"test_name": { "type": "keyword" },
"test_status": { "type": "keyword" },
Expand Down

0 comments on commit 9a3bc30

Please sign in to comment.