2018-05-30 12:00:13 +02:00
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Test
|
|
|
|
import org.junit.rules.RuleChain
|
|
|
|
import util.*
|
|
|
|
|
|
|
|
import static org.hamcrest.Matchers.containsString
|
|
|
|
import static org.junit.Assert.assertFalse
|
|
|
|
import static org.junit.Assert.assertThat
|
|
|
|
|
|
|
|
class PipelineStashFilesAfterBuildTest extends BasePiperTest {
|
|
|
|
JenkinsStepRule jsr = new JenkinsStepRule(this)
|
|
|
|
JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
|
|
|
|
JenkinsReadJsonRule jrj = new JenkinsReadJsonRule(this)
|
|
|
|
|
|
|
|
@Rule
|
|
|
|
public RuleChain rules = Rules
|
|
|
|
.getCommonRules(this)
|
2018-08-31 10:22:43 +02:00
|
|
|
.around(new JenkinsReadYamlRule(this))
|
2018-05-30 12:00:13 +02:00
|
|
|
.around(jrj)
|
|
|
|
.around(jlr)
|
|
|
|
.around(jsr)
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testStashAfterBuild() {
|
|
|
|
helper.registerAllowedMethod("fileExists", [String.class], {
|
|
|
|
searchTerm ->
|
|
|
|
return false
|
|
|
|
})
|
|
|
|
jsr.step.call(
|
|
|
|
script: nullScript,
|
|
|
|
juStabUtils: utils
|
|
|
|
)
|
|
|
|
// asserts
|
|
|
|
assertFalse(jlr.log.contains('Stash content: checkmarx'))
|
2018-06-01 12:33:06 +02:00
|
|
|
assertThat(jlr.log, containsString('Stash content: classFiles'))
|
|
|
|
assertThat(jlr.log, containsString('Stash content: sonar'))
|
2018-05-30 12:00:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testStashAfterBuildWithCheckmarx() {
|
|
|
|
helper.registerAllowedMethod("fileExists", [String.class], {
|
|
|
|
searchTerm ->
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
jsr.step.call(
|
|
|
|
script: nullScript,
|
|
|
|
juStabUtils: utils,
|
|
|
|
runCheckmarx: true
|
|
|
|
)
|
|
|
|
// asserts
|
2018-06-01 12:33:06 +02:00
|
|
|
assertThat(jlr.log, containsString('Stash content: checkmarx'))
|
|
|
|
assertThat(jlr.log, containsString('Stash content: classFiles'))
|
|
|
|
assertThat(jlr.log, containsString('Stash content: sonar'))
|
2018-05-30 12:00:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testStashAfterBuildWithCheckmarxConfig() {
|
|
|
|
helper.registerAllowedMethod("fileExists", [String.class], {
|
|
|
|
searchTerm ->
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
jsr.step.call(
|
|
|
|
script: [commonPipelineEnvironment: [configuration: [steps: [executeCheckmarxScan: [checkmarxProject: 'TestProject']]]]],
|
|
|
|
juStabUtils: utils,
|
|
|
|
)
|
|
|
|
// asserts
|
2018-06-01 12:33:06 +02:00
|
|
|
assertThat(jlr.log, containsString('Stash content: checkmarx'))
|
|
|
|
assertThat(jlr.log, containsString('Stash content: classFiles'))
|
|
|
|
assertThat(jlr.log, containsString('Stash content: sonar'))
|
2018-05-30 12:00:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|