2017-07-11 15:12:03 +02:00
|
|
|
import com.sap.piper.FileUtils
|
|
|
|
import com.sap.piper.Version
|
2018-03-19 19:29:41 +02:00
|
|
|
import com.sap.piper.tools.JavaArchiveDescriptor
|
|
|
|
import com.sap.piper.tools.ToolDescriptor
|
|
|
|
|
2018-10-09 17:09:55 +02:00
|
|
|
import groovy.transform.Field
|
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
import hudson.AbortException
|
|
|
|
|
2018-10-09 17:09:55 +02:00
|
|
|
@Field STEP_NAME = 'toolValidate'
|
2017-11-24 16:59:34 +02:00
|
|
|
|
2018-08-30 16:33:07 +02:00
|
|
|
void call(Map parameters = [:]) {
|
2017-07-11 15:12:03 +02:00
|
|
|
|
|
|
|
handlePipelineStepErrors (stepName: 'toolValidate', stepParameters: parameters) {
|
|
|
|
|
2018-04-10 18:23:44 +02:00
|
|
|
echo '[WARNING][toolValidate] This step is deprecated, and it will be removed in future versions. Validation is automatically done inside the steps.'
|
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
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':
|
2018-03-19 19:29:41 +02:00
|
|
|
def java = new ToolDescriptor('Java', 'JAVA_HOME', '', '/bin/', 'java', '1.8.0', '-version 2>&1')
|
|
|
|
java.verifyVersion(this, [:])
|
2018-03-05 18:30:34 +02:00
|
|
|
return
|
|
|
|
case 'mta':
|
2018-03-19 19:29:41 +02:00
|
|
|
def java = new ToolDescriptor('Java', 'JAVA_HOME', '', '/bin/', 'java', '1.8.0', '-version 2>&1')
|
2018-04-17 16:53:04 +02:00
|
|
|
def mta = new JavaArchiveDescriptor('SAP Multitarget Application Archive Builder', 'MTA_JAR_LOCATION', 'mtaJarLocation', '1.0.6', '-v', java)
|
2018-03-19 19:29:41 +02:00
|
|
|
mta.verifyVersion(this, [mtaJarLocation: home])
|
2018-03-05 18:30:34 +02:00
|
|
|
return
|
|
|
|
case 'neo':
|
2018-07-17 11:47:39 +02:00
|
|
|
def neo = new ToolDescriptor('SAP Cloud Platform Console Client', 'NEO_HOME', 'neoHome', '/tools/', 'neo.sh', null, 'version')
|
2018-03-19 19:29:41 +02:00
|
|
|
neo.verifyVersion(this, [neoHome: home])
|
2018-03-05 18:30:34 +02:00
|
|
|
return
|
|
|
|
case 'cm':
|
2018-03-19 19:29:41 +02:00
|
|
|
def cmCli = new ToolDescriptor('Change Management Command Line Interface', 'CM_CLI_HOME', 'cmCliHome', '/bin/', 'cmclient', '0.0.1', '-v')
|
|
|
|
cmCli.verifyVersion(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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|