2020-09-24 13:47:20 +02:00
|
|
|
import org.junit.After
|
|
|
|
import org.junit.Before
|
2018-05-30 12:00:13 +02:00
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Test
|
|
|
|
import org.junit.rules.RuleChain
|
|
|
|
import util.*
|
2020-09-24 13:47:20 +02:00
|
|
|
import com.sap.piper.Utils
|
2018-05-30 12:00:13 +02:00
|
|
|
|
|
|
|
import static org.hamcrest.Matchers.containsString
|
|
|
|
import static org.junit.Assert.assertFalse
|
|
|
|
import static org.junit.Assert.assertThat
|
|
|
|
|
2020-09-24 13:47:20 +02:00
|
|
|
|
2018-05-30 12:00:13 +02:00
|
|
|
class PipelineStashFilesAfterBuildTest 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: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:25:42 +02:00
|
|
|
.around(stepRule)
|
2018-05-30 12:00:13 +02:00
|
|
|
|
2020-09-24 13:47:20 +02:00
|
|
|
@Before
|
|
|
|
public void setup() {
|
|
|
|
Utils.metaClass.echo = { def m -> }
|
|
|
|
}
|
|
|
|
|
|
|
|
@After
|
|
|
|
public void tearDown() {
|
|
|
|
Utils.metaClass = null
|
|
|
|
}
|
|
|
|
|
2018-05-30 12:00:13 +02:00
|
|
|
@Test
|
|
|
|
void testStashAfterBuild() {
|
|
|
|
helper.registerAllowedMethod("fileExists", [String.class], {
|
|
|
|
searchTerm ->
|
|
|
|
return true
|
|
|
|
})
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.pipelineStashFilesAfterBuild(
|
2018-05-30 12:00:13 +02:00
|
|
|
script: nullScript,
|
|
|
|
juStabUtils: utils,
|
|
|
|
runCheckmarx: true
|
|
|
|
)
|
|
|
|
// asserts
|
2019-01-22 10:22:15 +02:00
|
|
|
assertThat(loggingRule.log, containsString('Stash content: checkmarx'))
|
|
|
|
assertThat(loggingRule.log, containsString('Stash content: classFiles'))
|
|
|
|
assertThat(loggingRule.log, containsString('Stash content: sonar'))
|
2018-05-30 12:00:13 +02:00
|
|
|
}
|
|
|
|
}
|