Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/test/groovy/JunitAndStoreStepTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.junit.Before
import org.junit.Test
import static org.junit.Assert.assertFalse
import static org.junit.Assert.assertTrue

class JunitAndStoreStepTests extends ApmBasePipelineTest {
Expand Down Expand Up @@ -68,6 +69,8 @@ class JunitAndStoreStepTests extends ApmBasePipelineTest {
script.call(stashedTestReports: [:], testResults: '*.xml', id: 'acme')
printCallStack()
assertTrue(assertMethodCallContainsPattern('junit', 'testResults=*.xml'))
assertFalse(assertMethodCallContainsPattern('junit', 'id'))
assertFalse(assertMethodCallContainsPattern('junit', 'stashedTestReports'))
assertTrue(assertMethodCallContainsPattern('stash', 'includes=*.xml, allowEmpty=true, name=acme-'))
assertJobStatusSuccess()
}
Expand Down
3 changes: 2 additions & 1 deletion vars/junitAndStore.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ populated later on with the runbld post build step.
def call(Map args = [:]) {
def stashedTestReports = args.containsKey('stashedTestReports') ? args.stashedTestReports : error('junitAndStore: stashedTestReports param is required')
def testResults = args.containsKey('testResults') ? args.testResults : error('junitAndStore: testResults param is required')
junit(args)
def junitArgs = args.findAll { k,v -> !(k.equals('id') || k.equals('stashedTestReports')) }
junit(junitArgs)
// args.id could be null in some cases, so let's use the currentmilliseconds
def suffix = new java.util.Date().getTime()
def stageName = args.id ? "${args.id?.replaceAll('[\\W]|_', '-')}-${suffix}" : "uncategorized-${suffix}"
Expand Down