Skip to content

Commit

Permalink
Update JTEPipelineSpecification.groovy
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-terrana authored May 11, 2022
1 parent e83a9d4 commit bd2e9cf
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions resources/test/JTEPipelineSpecification.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ public class JTEPipelineSpecification extends JenkinsPipelineSpecification {
@Override
Script loadPipelineScriptForTest(String _path) {

String[] path_parts = _path.split( "/" )

String filename = path_parts[path_parts.length-1]

String resource_path = "/"
if( path_parts.length >= 2 ) {
resource_path = String.join( "/", path_parts[0..path_parts.length-2] )
resource_path = "/${resource_path}/"
}
String[] path_parts = _path.split( "/" )

GroovyScriptEngine script_engine = new GroovyScriptEngine(generateScriptClasspath(resource_path))
String filename = path_parts[path_parts.length-1]

String resource_path = "/"
if( path_parts.length >= 2 ) {
resource_path = String.join( "/", path_parts[0..path_parts.length-2] )
resource_path = "/${resource_path}/"
}

GroovyScriptEngine script_engine = new GroovyScriptEngine(generateScriptClasspath(resource_path))
CompilerConfiguration cc = script_engine.getConfig()
// define auto importing of JTE hook annotations
ImportCustomizer ic = new ImportCustomizer()
Expand All @@ -33,19 +33,13 @@ public class JTEPipelineSpecification extends JenkinsPipelineSpecification {
script_engine.setConfig(cc)

Class<Script> script_class = script_engine.loadScriptByName( "${filename}" )

Script script = script_class.newInstance()

addPipelineMocksToObjects( script )
addPipelineMocksToObjects(script)

if( SourceVersion.isName( script_class.getSimpleName() ) ) {
return script
} else {
return new InvalidlyNamedScriptWrapper( script )
}
return SourceVersion.isName(script_class.getSimpleName()) ? script : new InvalidlyNamedScriptWrapper(script)
}

Script loadPipelineScriptForStep(String lib, String step) {
loadPipelineScriptForTest("${lib}/steps/${step}.groovy")
}
}
}

0 comments on commit bd2e9cf

Please sign in to comment.