mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
6dc13801b0
Disable download logs in Maven by default This commit adds a flag to Maven by default, which disables the messages like "Downloading from central". The logger is set to level "warn", so errors will still be visible, but successful messages won't clutter logs anymore. This option is also set by default in the GitLab CI template file for maven. See [1] for reference on the option. 1: https://stackoverflow.com/a/35653426/8843830
73 lines
2.7 KiB
Groovy
73 lines
2.7 KiB
Groovy
import org.junit.Rule
|
|
import org.junit.Test
|
|
import org.junit.rules.RuleChain
|
|
import util.BasePiperTest
|
|
import util.JenkinsDockerExecuteRule
|
|
import util.JenkinsShellCallRule
|
|
import util.JenkinsStepRule
|
|
import util.Rules
|
|
|
|
import static org.junit.Assert.assertEquals
|
|
import static org.junit.Assert.assertTrue
|
|
|
|
class MavenExecuteTest extends BasePiperTest {
|
|
|
|
Map dockerParameters
|
|
|
|
private JenkinsShellCallRule jscr = new JenkinsShellCallRule(this)
|
|
private JenkinsDockerExecuteRule jder = new JenkinsDockerExecuteRule(this)
|
|
private JenkinsStepRule jsr = new JenkinsStepRule(this)
|
|
|
|
@Rule
|
|
public RuleChain ruleChain = Rules
|
|
.getCommonRules(this)
|
|
.around(jder)
|
|
.around(jscr)
|
|
.around(jsr)
|
|
|
|
@Test
|
|
void testExecuteBasicMavenCommand() throws Exception {
|
|
|
|
jsr.step.mavenExecute(script: nullScript, goals: 'clean install')
|
|
assertEquals('maven:3.5-jdk-7', jder.dockerParams.dockerImage)
|
|
|
|
assert jscr.shell[0] == 'mvn --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn clean install'
|
|
}
|
|
|
|
@Test
|
|
void testExecuteBasicMavenCommandWithDownloadLogsEnabled() throws Exception {
|
|
|
|
jsr.step.mavenExecute(script: nullScript, goals: 'clean install', logSuccessfulMavenTransfers: true)
|
|
assertEquals('maven:3.5-jdk-7', jder.dockerParams.dockerImage)
|
|
|
|
assert jscr.shell[0] == 'mvn --batch-mode clean install'
|
|
}
|
|
|
|
@Test
|
|
void testExecuteMavenCommandWithParameter() throws Exception {
|
|
|
|
jsr.step.mavenExecute(
|
|
script: nullScript,
|
|
dockerImage: 'maven:3.5-jdk-8-alpine',
|
|
goals: 'clean install',
|
|
globalSettingsFile: 'globalSettingsFile.xml',
|
|
projectSettingsFile: 'projectSettingsFile.xml',
|
|
pomPath: 'pom.xml',
|
|
flags: '-o',
|
|
m2Path: 'm2Path',
|
|
defines: '-Dmaven.tests.skip=true')
|
|
assertEquals('maven:3.5-jdk-8-alpine', jder.dockerParams.dockerImage)
|
|
String mvnCommand = "mvn --global-settings 'globalSettingsFile.xml' -Dmaven.repo.local='m2Path' --settings 'projectSettingsFile.xml' --file 'pom.xml' -o --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn clean install -Dmaven.tests.skip=true"
|
|
assertTrue(jscr.shell.contains(mvnCommand))
|
|
}
|
|
|
|
@Test
|
|
void testMavenCommandForwardsDockerOptions() throws Exception {
|
|
|
|
jsr.step.mavenExecute(script: nullScript, goals: 'clean install')
|
|
assertEquals('maven:3.5-jdk-7', jder.dockerParams.dockerImage)
|
|
|
|
assert jscr.shell[0] == 'mvn --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn clean install'
|
|
}
|
|
}
|