Last active
June 19, 2018 15:57
-
-
Save mkp246/5bba5e5e179b1728183f52f3311b26db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rawPomUrl ="<raw pom Url" | |
def pom = new URL(rawPomUrl).getText() | |
def xmlRootNode = new XmlParser().parseText(pom) | |
def jsonText = '''{ | |
"disable_edit_json": true, | |
"disable_properties": true, | |
"no_additional_properties": true, | |
"disable_collapse": true, | |
"disable_array_add": true, | |
"disable_array_delete": true, | |
"disable_array_reorder": true, | |
"theme": "bootstrap2", | |
"iconlib": "fontawesome4", | |
"schema": { | |
"type": "object", | |
"title" : "pom properties parameters", | |
"properties": {} | |
}, | |
"startval": {} | |
}''' | |
import groovy.json.JsonBuilder | |
import groovy.json.JsonSlurper | |
import org.boon.Boon | |
def slurped = new JsonSlurper().parseText(jsonText) | |
def builder = new JsonBuilder(slurped) | |
def order = 1 | |
for(prop in xmlRootNode.properties[0].children()){ | |
def name = prop.name().getLocalPart() | |
def value = prop.text() | |
builder.content.schema.properties[name] = {} | |
builder.content.startval[name] = value | |
order++ | |
//printf("%s:%s\n", name, value) | |
} | |
return Boon.fromJson(builder.toString()) | |
//===========================================// | |
import groovy.json.JsonBuilder | |
import groovy.json.JsonSlurper | |
import hudson.EnvVars | |
import hudson.model.* | |
class VariableInjectionAction implements EnvironmentContributingAction { | |
private String key | |
private String value | |
public VariableInjectionAction(String key, String value) { | |
this.key = key | |
this.value = value | |
} | |
public void buildEnvVars(AbstractBuild build, EnvVars envVars) { | |
if (envVars != null && key != null && value != null) { | |
envVars.put(key, value); | |
} | |
} | |
public String getDisplayName() { | |
return "VariableInjectionAction"; | |
} | |
public String getIconFileName() { | |
return null; | |
} | |
public String getUrlName() { | |
return null; | |
} | |
} | |
def buildEnv = build.getEnvironment().get("BUILD_PARAMETERS") | |
def slurped = new JsonSlurper().parseText(buildEnv) | |
def builder = new JsonBuilder(slurped) | |
def MAVEN_JENKINS_PARAMS = "" | |
for(entry in builder.getContent().entrySet()){ | |
MAVEN_JENKINS_PARAMS <<= "\"-D$entry.key=$entry.value\" " | |
} | |
Thread.currentThread().executable.addAction(new VariableInjectionAction('MAVEN_JENKINS_PARAMS', MAVEN_JENKINS_PARAMS.toString())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment