1
0

Конфиг по умолчанию, мерж конфигураций, интеграционные тесты

This commit is contained in:
Nikita Gryzlov
2020-04-03 15:17:12 +03:00
parent 9d1edee928
commit 6f21593e0b
6 changed files with 126 additions and 15 deletions

View File

@@ -0,0 +1,77 @@
import org.apache.commons.io.IOUtils
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition
import org.jenkinsci.plugins.workflow.job.WorkflowJob
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.jvnet.hudson.test.JenkinsRule
import java.nio.charset.StandardCharsets
class jobConfigurationTest {
@Rule
public JenkinsRule rule = new JenkinsRule()
@Before
void configureGlobalGitLibraries() {
RuleBootstrapper.setup(rule)
}
@Test
void "jobConfiguration should not fail without file"() {
def pipeline = """
pipeline {
agent any
stages {
stage('test') {
steps {
echo jobConfiguration().toString()
}
}
}
}
""".stripIndent()
final CpsFlowDefinition flow = new CpsFlowDefinition(pipeline, true)
final WorkflowJob workflowJob = rule.createProject(WorkflowJob, 'project')
workflowJob.definition = flow
rule.buildAndAssertSuccess(workflowJob)
}
@Test
void "jobConfiguration should merge configurations"() {
def file = IOUtils.resourceToString(
'jobConfiguration.json',
StandardCharsets.UTF_8,
this.getClass().getClassLoader()
);
def writeFile = """
writeFile text: \"\"\"$file\"\"\", file: 'jobConfiguration.json'
"""
def pipeline = """
pipeline {
agent any
stages {
stage('test') {
steps {
$writeFile
echo jobConfiguration().toString()
}
}
}
}
""".stripIndent()
final CpsFlowDefinition flow = new CpsFlowDefinition(pipeline, true)
final WorkflowJob workflowJob = rule.createProject(WorkflowJob, 'project')
workflowJob.definition = flow
def run = rule.buildAndAssertSuccess(workflowJob)
rule.assertLogContains('v8version=8.3.12.1500', run)
rule.assertLogContains('sonarScannerToolName=sonar-scanner', run)
}
}

View File

@@ -0,0 +1,3 @@
{
"v8version": "8.3.12.1500"
}