1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/test/groovy/com/sap/piper/versioning/MavenArtifactVersioningTest.groovy
Florian Wilhelm 6dc13801b0
Disable download logs in Maven by default (#159)
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
2018-06-06 14:42:47 +02:00

56 lines
1.8 KiB
Groovy

package com.sap.piper.versioning
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.RuleChain
import util.BasePiperTest
import util.JenkinsReadMavenPomRule
import util.JenkinsShellCallRule
import util.Rules
import static org.junit.Assert.assertEquals
class MavenArtifactVersioningTest extends BasePiperTest{
Map dockerParameters
def commonPipelineEnvironment
MavenArtifactVersioning av
JenkinsShellCallRule jscr = new JenkinsShellCallRule(this)
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(jscr)
.around(new JenkinsReadMavenPomRule(this, 'test/resources/MavenArtifactVersioning'))
@Before
void init() {
dockerParameters = [:]
helper.registerAllowedMethod("dockerExecute", [Map.class, Closure.class],
{ parameters, closure ->
dockerParameters = parameters
closure()
})
}
@Test
void testVersioning() {
av = new MavenArtifactVersioning(nullScript, [filePath: 'pom.xml'])
assertEquals('1.2.3', av.getVersion())
av.setVersion('1.2.3-20180101')
assertEquals('mvn --file \'pom.xml\' --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn versions:set -DnewVersion=1.2.3-20180101', jscr.shell[0])
}
@Test
void testVersioningCustomFilePathSnapshot() {
av = new MavenArtifactVersioning(nullScript, [filePath: 'snapshot/pom.xml'])
assertEquals('1.2.3', av.getVersion())
av.setVersion('1.2.3-20180101')
assertEquals('mvn --file \'snapshot/pom.xml\' --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn versions:set -DnewVersion=1.2.3-20180101', jscr.shell[0])
}
}