Skip to content

Commit

Permalink
[FIXED JENKINS-17073] added Options field to specify logger
Browse files Browse the repository at this point in the history
  • Loading branch information
ssogabe committed Mar 18, 2013
1 parent 4b58911 commit 0c5382a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
24 changes: 21 additions & 3 deletions src/main/java/hudson/plugins/phing/PhingBuilder.java
Expand Up @@ -81,6 +81,12 @@ public final class PhingBuilder extends Builder {
* @since 0.9
*/
private final boolean useModuleRoot;

/**
* Additional options to be passed to Phing.
* @since 0.12
*/
private final String options;

public String getBuildFile() {
return buildFile;
Expand All @@ -102,14 +108,20 @@ public boolean isUseModuleRoot() {
return useModuleRoot;
}

public String getOptions() {
return options;
}

@DataBoundConstructor
public PhingBuilder(String name, String buildFile, String targets, String properties, boolean useModuleRoot) {
public PhingBuilder(String name, String buildFile, String targets, String properties,
boolean useModuleRoot, String options) {
super();
this.name = Util.fixEmptyAndTrim(name);
this.buildFile = Util.fixEmptyAndTrim(buildFile);
this.targets = Util.fixEmptyAndTrim(targets);
this.properties = Util.fixEmptyAndTrim(properties);
this.useModuleRoot = useModuleRoot;
this.options = Util.fixEmptyAndTrim(options);
}

public PhingInstallation getPhing() {
Expand Down Expand Up @@ -169,8 +181,14 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
args.addKeyValuePairs("-D", build.getBuildVariables(), sensitiveVars);
args.addKeyValuePairsFromPropertyString("-D", properties, vr, sensitiveVars);

// avoid printing esc sequence
args.add("-logger", "phing.listener.DefaultLogger");
String expandedOptions = Util.replaceMacro(env.expand(options), vr);
if (expandedOptions == null || !expandedOptions.contains("-logger ")) {
// avoid printing esc sequence
args.add("-logger", "phing.listener.DefaultLogger");
}
if (expandedOptions != null) {
args.addTokenized(expandedOptions.replaceAll("[\t\r\n]", " "));
}

// Environment variables
if (pi != null && pi.getPhingHome() != null) {
Expand Down
Expand Up @@ -20,8 +20,11 @@
<f:entry title="${%Phing Build File}" help="${rootURL}/../plugin/phing/help-buildfile.html">
<f:textbox name="phingBuilder.buildFile" value="${instance.buildFile}" />
</f:entry>
<f:entry title="${%Options}" >
<f:textarea name="phingBuilder.options" value="${instance.options}" />
</f:entry>
<f:entry title="${%Properties}" help="${rootURL}/../plugin/phing/help-properties.html">
<f:textarea name="phingBuilder.properties" value="${instance.properties}"/>
<f:expandableTextbox name="phingBuilder.properties" value="${instance.properties}"/>
</f:entry>
<f:entry title="">
<label>
Expand Down
Expand Up @@ -4,3 +4,4 @@ Phing\ Build\ File = \u30d3\u30eb\u30c9\u30d5\u30a1\u30a4\u30eb
Targets = \u30bf\u30fc\u30b2\u30c3\u30c8
Properties = \u30d7\u30ed\u30d1\u30c6\u30a3
Use\ ModuleRoot\ as\ working\ directory=\u30e2\u30b8\u30e5\u30fc\u30eb\u30eb\u30fc\u30c8\u3092\u30ef\u30fc\u30ad\u30f3\u30b0\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3068\u3057\u3066\u4f7f\u7528
Options=\u30aa\u30d7\u30b7\u30e7\u30f3
Expand Up @@ -55,7 +55,7 @@ protected void tearDown() throws Exception {

public void testConfigsubmit() throws Exception {
FreeStyleProject p = createFreeStyleProject();
PhingBuilder builder = new PhingBuilder("Default", "build.xml", "install", null, true);
PhingBuilder builder = new PhingBuilder("Default", "build.xml", "install", null, true, null);
p.getBuildersList().add(builder);

HtmlForm form = webClient.goTo(p.getUrl() + "/configure").getFormByName("config");
Expand Down

0 comments on commit 0c5382a

Please sign in to comment.