1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

use classloader

This commit is contained in:
Christopher Fenner 2019-07-05 21:40:10 +02:00
parent a449adf4bc
commit a896487032
No known key found for this signature in database
GPG Key ID: 749881F766EA636F

View File

@ -20,12 +20,15 @@ static boolean hasTestFailures(build){
}
static boolean addWarningsNGParser(String id, String name, String regex, String script, String example = ''){
if(io.jenkins.plugins.analysis.warnings.groovy.ParserConfiguration.getInstance().contains(id)){
def classLoader = this.getClass().getClassLoader()
config = classLoader.loadClass('io.jenkins.plugins.analysis.warnings.groovy.ParserConfiguration', true, false)?.getInstance()
if(config.contains(id)){
return false
}else{
io.jenkins.plugins.analysis.warnings.groovy.ParserConfiguration.getInstance().setParsers(
io.jenkins.plugins.analysis.warnings.groovy.ParserConfiguration.getInstance().getParsers().plus(
new io.jenkins.plugins.analysis.warnings.groovy.GroovyParser(id, name, regex, script, example)
config.setParsers(
config.getParsers().plus(
classLoader.loadClass('io.jenkins.plugins.analysis.warnings.groovy.GroovyParser', true, false)?.newInstance(id, name, regex, script, example)
)
)
return true