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 {
|
2019-01-22 10:25:42 +02:00
|
|
|
JenkinsStepRule stepRule = new JenkinsStepRule(this)
|
2019-01-22 10:22:15 +02:00
|
|
|
JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
|
2019-01-22 10:19:28 +02:00
|
|
|
JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this)
|
2019-01-22 10:38:37 +02:00
|
|
|
//JenkinsReadJsonRule readJsonRule = new JenkinsReadJsonRule(this)
|
2018-05-30 12:00:13 +02:00
|
|
|
|
|
|
|
@Rule
|
|
|
|
public RuleChain rules = Rules
|
|
|
|
.getCommonRules(this)
|
2018-08-31 10:22:43 +02:00
|
|
|
.around(new JenkinsReadYamlRule(this))
|
2019-01-22 10:38:37 +02:00
|
|
|
//.around(readJsonRule)
|
2019-01-22 10:22:15 +02:00
|
|
|
.around(loggingRule)
|
2019-01-22 10:19:28 +02:00
|
|
|
.around(shellRule)
|
2019-01-22 10:25:42 +02:00
|
|
|
.around(stepRule)
|
2018-05-30 12:00:13 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
void testStashBeforeBuildNoOpa() {
|
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.pipelineStashFilesBeforeBuild(script: nullScript, juStabUtils: utils)
|
2018-05-30 12:00:13 +02:00
|
|
|
|
|
|
|
// asserts
|
2019-01-22 10:19:28 +02:00
|
|
|
assertEquals('mkdir -p gitmetadata', shellRule.shell[0])
|
|
|
|
assertEquals('cp -rf .git/* gitmetadata', shellRule.shell[1])
|
|
|
|
assertEquals('chmod -R u+w gitmetadata', shellRule.shell[2])
|
2018-05-30 12:00:13 +02:00
|
|
|
|
2019-01-22 10:22:15 +02:00
|
|
|
assertThat(loggingRule.log, containsString('Stash content: buildDescriptor'))
|
|
|
|
assertThat(loggingRule.log, containsString('Stash content: deployDescriptor'))
|
|
|
|
assertThat(loggingRule.log, containsString('Stash content: git'))
|
|
|
|
assertFalse(loggingRule.log.contains('Stash content: opa5'))
|
|
|
|
assertThat(loggingRule.log, containsString('Stash content: opensourceConfiguration'))
|
|
|
|
assertThat(loggingRule.log, containsString('Stash content: pipelineConfigAndTests'))
|
|
|
|
assertThat(loggingRule.log, containsString('Stash content: securityDescriptor'))
|
|
|
|
assertThat(loggingRule.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
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.pipelineStashFilesBeforeBuild(script: nullScript, juStabUtils: utils, runOpaTests: true)
|
2018-05-30 12:00:13 +02:00
|
|
|
|
|
|
|
// asserts
|
2019-01-22 10:22:15 +02:00
|
|
|
assertThat(loggingRule.log, containsString('Stash content: buildDescriptor'))
|
|
|
|
assertThat(loggingRule.log, containsString('Stash content: deployDescriptor'))
|
|
|
|
assertThat(loggingRule.log, containsString('Stash content: git'))
|
|
|
|
assertThat(loggingRule.log, containsString('Stash content: opa5'))
|
|
|
|
assertThat(loggingRule.log, containsString('Stash content: opensourceConfiguration'))
|
|
|
|
assertThat(loggingRule.log, containsString('Stash content: pipelineConfigAndTests'))
|
|
|
|
assertThat(loggingRule.log, containsString('Stash content: securityDescriptor'))
|
|
|
|
assertThat(loggingRule.log, containsString('Stash content: tests'))
|
2018-05-30 12:00:13 +02:00
|
|
|
}
|
|
|
|
}
|