Skip to content

Commit

Permalink
[FIXED JENKINS-12078] Working directory of Phing set to the directory…
Browse files Browse the repository at this point in the history
… of your custom build script

instead of Jenkins workspace
  • Loading branch information
ssogabe committed Dec 21, 2011
1 parent c1b8539 commit 2974f1d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/main/java/hudson/plugins/phing/PhingBuilder.java
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2008-2011, Jenkins project, Seiji Sogabe
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand Down Expand Up @@ -76,6 +76,12 @@ public final class PhingBuilder extends Builder {
*/
private final String properties;

/**
* Whether uses ModuleRoot as working directory or not.
* @since 0.9
*/
private final boolean useModuleRoot;

public String getBuildFile() {
return buildFile;
}
Expand All @@ -92,13 +98,18 @@ public String getProperties() {
return properties;
}

public boolean isUseModuleRoot() {
return useModuleRoot;
}

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

public PhingInstallation getPhing() {
Expand Down Expand Up @@ -171,12 +182,16 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
args = args.toWindowsCommand();
}

// Working Directory
// since 0.9
FilePath working = useModuleRoot ? build.getModuleRoot() : buildScript.getParent();

final long startTime = System.currentTimeMillis();
try {
PhingConsoleAnnotator pca = new PhingConsoleAnnotator(listener.getLogger(), build.getCharset());
int result;
try {
result = launcher.launch().cmds(args).envs(env).stdout(pca).pwd(buildScript.getParent()).join();
result = launcher.launch().cmds(args).envs(env).stdout(pca).pwd(working).join();
} finally {
pca.forceEol();
}
Expand Down
Expand Up @@ -22,6 +22,9 @@
<f:entry title="${%Properties}" help="${rootURL}/../plugin/phing/help-properties.html">
<f:textarea name="phingBuilder.properties" value="${instance.properties}"/>
</f:entry>
<f:entry title="${%Use ModuleRoot as working directory}">
<f:checkbox name="phingBuilder.useModuleRoot" value="${instance.useModuleRoot}" />
</f:entry>
</f:advanced>

</j:jelly>

0 comments on commit 2974f1d

Please sign in to comment.