1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-03-05 15:15:44 +02:00

remove outdated code from step toolValidate

This commit is contained in:
Alejandra Ferreiro Vidal 2018-03-05 17:30:34 +01:00
parent dafd48504e
commit a1a6467495
2 changed files with 45 additions and 53 deletions

View File

@ -32,11 +32,25 @@ class ToolValidateTest extends BasePipelineTest {
.around(jsr)
private static home
private static mtaJar
private static neoExecutable
private static cmCliExecutable
@BeforeClass
static void createTestFiles() {
home = "${tmp.getRoot()}"
tmp.newFolder('bin')
tmp.newFolder('bin', 'java')
tmp.newFile('mta.jar')
tmp.newFolder('tools')
tmp.newFile('tools/neo.sh')
tmp.newFile('bin/cmclient')
mtaJar = "$home/mta.jar"
neoExecutable = "$home/tools/neo.sh"
cmCliExecutable = "$home/bin/cmclient"
}
@Before
@ -88,7 +102,7 @@ class ToolValidateTest extends BasePipelineTest {
@Test
void unableToValidateJavaTest() {
thrown.expect(AbortException)
thrown.expectMessage('The validation of Java failed.')
thrown.expectMessage('The verification of Java failed.')
helper.registerAllowedMethod('sh', [Map], { Map m -> getNoVersion(m) })
@ -98,7 +112,7 @@ class ToolValidateTest extends BasePipelineTest {
@Test
void unableToValidateMtaTest() {
thrown.expect(AbortException)
thrown.expectMessage('The validation of SAP Multitarget Application Archive Builder failed.')
thrown.expectMessage('The verification of SAP Multitarget Application Archive Builder failed.')
helper.registerAllowedMethod('sh', [Map], { Map m -> getNoVersion(m) })
@ -108,7 +122,7 @@ class ToolValidateTest extends BasePipelineTest {
@Test
void unableToValidateNeoTest() {
thrown.expect(AbortException)
thrown.expectMessage('The validation of SAP Cloud Platform Console Client failed.')
thrown.expectMessage('The verification of SAP Cloud Platform Console Client failed.')
helper.registerAllowedMethod('sh', [Map], { Map m -> getNoVersion(m) })
@ -118,7 +132,7 @@ class ToolValidateTest extends BasePipelineTest {
@Test
void unableToValidateCmTest() {
thrown.expect(AbortException)
thrown.expectMessage('The validation of Change Management Command Line Interface failed.')
thrown.expectMessage('The verification of Change Management Command Line Interface failed.')
helper.registerAllowedMethod('sh', [Map], { Map m -> getNoVersion(m) })
@ -174,8 +188,8 @@ class ToolValidateTest extends BasePipelineTest {
jsr.step.call(tool: 'java', home: home)
assert jlr.log.contains('[toolValidate] Validating Java version 1.8.0 or compatible version.')
assert jlr.log.contains('[toolValidate] Java version 1.8.0 is installed.')
assert jlr.log.contains('Verifying Java version 1.8.0 or compatible version.')
assert jlr.log.contains('Java version 1.8.0 is installed.')
}
@Test
@ -184,8 +198,8 @@ class ToolValidateTest extends BasePipelineTest {
jsr.step.call(tool: 'mta', home: home)
assert jlr.log.contains('[toolValidate] Validating SAP Multitarget Application Archive Builder version 1.0.6 or compatible version.')
assert jlr.log.contains('[toolValidate] SAP Multitarget Application Archive Builder version 1.0.6 is installed.')
assert jlr.log.contains('Verifying SAP Multitarget Application Archive Builder version 1.0.6 or compatible version.')
assert jlr.log.contains('SAP Multitarget Application Archive Builder version 1.0.6 is installed.')
}
@Test
@ -194,8 +208,8 @@ class ToolValidateTest extends BasePipelineTest {
jsr.step.call(tool: 'neo', home: home)
assert jlr.log.contains('[toolValidate] Validating SAP Cloud Platform Console Client version 3.39.10 or compatible version.')
assert jlr.log.contains('[toolValidate] SAP Cloud Platform Console Client version 3.39.10 is installed.')
assert jlr.log.contains('Verifying SAP Cloud Platform Console Client version 3.39.10 or compatible version.')
assert jlr.log.contains('SAP Cloud Platform Console Client version 3.39.10 is installed.')
}
@Test
@ -204,8 +218,8 @@ class ToolValidateTest extends BasePipelineTest {
jsr.step.call(tool: 'cm', home: home)
assert jlr.log.contains('[toolValidate] Validating Change Management Command Line Interface version 0.0.1 or compatible version.')
assert jlr.log.contains('[toolValidate] Change Management Command Line Interface version 0.0.1 is installed.')
assert jlr.log.contains('Verifying Change Management Command Line Interface version 0.0.1 or compatible version.')
assert jlr.log.contains('Change Management Command Line Interface version 0.0.1 is installed.')
}
private getNoVersion(Map m) {

View File

@ -1,5 +1,7 @@
import com.sap.piper.FileUtils
import com.sap.piper.Version
import com.sap.piper.tools.Tool
import com.sap.piper.tools.ToolVerifier
import hudson.AbortException
@ -16,48 +18,24 @@ def call(Map parameters = [:]) {
FileUtils.validateDirectoryIsNotEmpty(home)
switch(tool) {
case 'java': validateJava(home)
return
case 'mta': validateMta(home)
return
case 'neo': validateNeo(home)
return
case 'cm': validateCm(home)
return
case 'java':
def java = new Tool('Java', 'JAVA_HOME', '', '/bin/', 'java', '1.8.0', '-version 2>&1')
ToolVerifier.verifyToolVersion(java, this, [:], env)
return
case 'mta':
def mta = new Tool('SAP Multitarget Application Archive Builder', 'MTA_JAR_LOCATION', 'mtaJarLocation', '/', 'mta.jar', '1.0.6', '-v')
ToolVerifier.verifyToolVersion(mta, this, [mtaJarLocation: home], env)
return
case 'neo':
def neo = new Tool('SAP Cloud Platform Console Client', 'NEO_HOME', 'neoHome', '/tools/', 'neo.sh', '3.39.10', 'version')
ToolVerifier.verifyToolVersion(neo, this, [neoHome: home], env)
return
case 'cm':
def cmCli = new Tool('Change Management Command Line Interface', 'CM_CLI_HOME', 'cmCliHome', '/bin/', 'cmclient', '0.0.1', '-v')
ToolVerifier.verifyToolVersion(cmCli, this, [cmCliHome: home], env)
return
default:
throw new AbortException("The tool \'$tool\' is not supported. The following tools are supported: java, mta, neo and cm.")
throw new AbortException("The tool \'$tool\' is not supported. The following tools are supported: java, mta, neo and cm.")
}
}
}
def validateJava(home) {
validateTool('Java', home, "$home/bin/java -version 2>&1", new Version(1,8,0))
}
def validateMta(home) {
validateTool('SAP Multitarget Application Archive Builder', home, "$JAVA_HOME/bin/java -jar $home/mta.jar -v", new Version(1, 0, 6))
}
def validateNeo(home) {
validateTool('SAP Cloud Platform Console Client', home, "$home/tools/neo.sh version", new Version(3, 39, 10))
}
def validateCm(home) {
validateTool('Change Management Command Line Interface', home, "$home/bin/cmclient -v", new Version(0, 0, 1))
}
private validateTool(name, home, command, expectedVersion) {
echo "[toolValidate] Validating $name version ${expectedVersion.toString()} or compatible version."
def output
try {
output = sh returnStdout: true, script: command
} catch(AbortException e) {
throw new AbortException("The validation of $name failed. Please check $name home '$home': $e.message.")
}
def version = new Version(output)
if (!version.isCompatibleVersion(expectedVersion)) {
throw new AbortException("The installed version of $name is ${version.toString()}. Please install version ${expectedVersion.toString()} or a compatible version.")
}
echo "[toolValidate] $name version ${version.toString()} is installed."
}