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.*
|
|
|
|
|
|
|
|
class PipelineStashFilesBeforeBuildTest extends BasePiperTest {
|
|
|
|
JenkinsStepRule jsr = new JenkinsStepRule(this)
|
|
|
|
JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
|
|
|
|
JenkinsShellCallRule jscr = new JenkinsShellCallRule(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(jscr)
|
|
|
|
.around(jsr)
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testStashBeforeBuildNoOpa() {
|
|
|
|
|
|
|
|
jsr.step.call(script: nullScript, juStabUtils: utils)
|
|
|
|
|
|
|
|
// asserts
|
|
|
|
assertEquals('mkdir -p gitmetadata', jscr.shell[0])
|
|
|
|
assertEquals('cp -rf .git/* gitmetadata', jscr.shell[1])
|
|
|
|
assertEquals('chmod -R u+w gitmetadata', jscr.shell[2])
|
|
|
|
|
|
|
|
assertThat(jlr.log, containsString('Stash content: buildDescriptor'))
|
|
|
|
assertThat(jlr.log, containsString('Stash content: deployDescriptor'))
|
2018-06-01 12:33:06 +02:00
|
|
|
assertThat(jlr.log, containsString('Stash content: git'))
|
|
|
|
assertFalse(jlr.log.contains('Stash content: opa5'))
|
|
|
|
assertThat(jlr.log, containsString('Stash content: opensourceConfiguration'))
|
2018-05-30 12:00:13 +02:00
|
|
|
assertThat(jlr.log, containsString('Stash content: pipelineConfigAndTests'))
|
|
|
|
assertThat(jlr.log, containsString('Stash content: securityDescriptor'))
|
2018-06-01 12:33:06 +02:00
|
|
|
assertThat(jlr.log, containsString('Stash content: tests'))
|
2018-05-30 12:00:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2018-06-01 12:33:06 +02:00
|
|
|
void testStashBeforeBuildOpa() {
|
2018-05-30 12:00:13 +02:00
|
|
|
|
2018-06-01 12:33:06 +02:00
|
|
|
jsr.step.call(script: nullScript, juStabUtils: utils, runOpaTests: true)
|
2018-05-30 12:00:13 +02:00
|
|
|
|
|
|
|
// asserts
|
|
|
|
assertThat(jlr.log, containsString('Stash content: buildDescriptor'))
|
|
|
|
assertThat(jlr.log, containsString('Stash content: deployDescriptor'))
|
2018-06-01 12:33:06 +02:00
|
|
|
assertThat(jlr.log, containsString('Stash content: git'))
|
|
|
|
assertThat(jlr.log, containsString('Stash content: opa5'))
|
|
|
|
assertThat(jlr.log, containsString('Stash content: opensourceConfiguration'))
|
2018-05-30 12:00:13 +02:00
|
|
|
assertThat(jlr.log, containsString('Stash content: pipelineConfigAndTests'))
|
|
|
|
assertThat(jlr.log, containsString('Stash content: securityDescriptor'))
|
2018-06-01 12:33:06 +02:00
|
|
|
assertThat(jlr.log, containsString('Stash content: tests'))
|
2018-05-30 12:00:13 +02:00
|
|
|
}
|
|
|
|
}
|