2017-07-11 15:12:03 +02:00
|
|
|
import com.sap.piper.FileUtils
|
|
|
|
import com.sap.piper.Version
|
2018-03-05 18:30:34 +02:00
|
|
|
import com.sap.piper.tools.Tool
|
|
|
|
import com.sap.piper.tools.ToolVerifier
|
2017-07-11 15:12:03 +02:00
|
|
|
import hudson.AbortException
|
|
|
|
|
2017-11-24 16:59:34 +02:00
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
def call(Map parameters = [:]) {
|
|
|
|
|
|
|
|
handlePipelineStepErrors (stepName: 'toolValidate', stepParameters: parameters) {
|
|
|
|
|
|
|
|
def tool = parameters.tool
|
|
|
|
def home = parameters.home
|
|
|
|
|
|
|
|
if (!tool) throw new IllegalArgumentException("The parameter 'tool' can not be null or empty.")
|
|
|
|
if (!home) throw new IllegalArgumentException("The parameter 'home' can not be null or empty.")
|
|
|
|
|
2018-03-09 18:58:11 +02:00
|
|
|
FileUtils.validateDirectoryIsNotEmpty(this, home)
|
2017-07-11 15:12:03 +02:00
|
|
|
|
|
|
|
switch(tool) {
|
2018-03-05 18:30:34 +02:00
|
|
|
case 'java':
|
|
|
|
def java = new Tool('Java', 'JAVA_HOME', '', '/bin/', 'java', '1.8.0', '-version 2>&1')
|
2018-03-09 18:58:11 +02:00
|
|
|
ToolVerifier.verifyToolVersion(java, this, [:])
|
2018-03-05 18:30:34 +02:00
|
|
|
return
|
|
|
|
case 'mta':
|
|
|
|
def mta = new Tool('SAP Multitarget Application Archive Builder', 'MTA_JAR_LOCATION', 'mtaJarLocation', '/', 'mta.jar', '1.0.6', '-v')
|
2018-03-09 18:58:11 +02:00
|
|
|
ToolVerifier.verifyToolVersion(mta, this, [mtaJarLocation: home])
|
2018-03-05 18:30:34 +02:00
|
|
|
return
|
|
|
|
case 'neo':
|
|
|
|
def neo = new Tool('SAP Cloud Platform Console Client', 'NEO_HOME', 'neoHome', '/tools/', 'neo.sh', '3.39.10', 'version')
|
2018-03-09 18:58:11 +02:00
|
|
|
ToolVerifier.verifyToolVersion(neo, this, [neoHome: home])
|
2018-03-05 18:30:34 +02:00
|
|
|
return
|
|
|
|
case 'cm':
|
|
|
|
def cmCli = new Tool('Change Management Command Line Interface', 'CM_CLI_HOME', 'cmCliHome', '/bin/', 'cmclient', '0.0.1', '-v')
|
2018-03-09 18:58:11 +02:00
|
|
|
ToolVerifier.verifyToolVersion(cmCli, this, [cmCliHome: home])
|
2018-03-05 18:30:34 +02:00
|
|
|
return
|
2017-07-11 15:12:03 +02:00
|
|
|
default:
|
2018-03-05 18:30:34 +02:00
|
|
|
throw new AbortException("The tool \'$tool\' is not supported. The following tools are supported: java, mta, neo and cm.")
|
2017-07-11 15:12:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|