Skip to content
Permalink
Browse files

[FIXED JENKINS-5790] Expand tomcat context path with build variables

  • Loading branch information...
kinow committed Dec 7, 2013
1 parent 1e0a0fa commit ce2fc7f51ba35f9854d1d683ec72b2079c436282
Showing with 11 additions and 0 deletions.
  1. +11 −0 src/main/java/hudson/plugins/deploy/DeployPublisher.java
@@ -1,8 +1,10 @@
package hudson.plugins.deploy;

import hudson.EnvVars;
import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.Util;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.BuildListener;
@@ -11,6 +13,8 @@
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Notifier;
import hudson.tasks.Publisher;
import hudson.util.VariableResolver;

import org.kohsuke.stapler.DataBoundConstructor;

import java.io.IOException;
@@ -42,6 +46,9 @@ public DeployPublisher(ContainerAdapter adapter, String war, String contextPath,

@Override
public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
// expand context path using build env variables
String contextPath = expandVariable(build.getBuildVariableResolver(),
build.getEnvironment(listener), this.contextPath);
if (build.getResult().equals(Result.SUCCESS) || onFailure) {
for (FilePath warFile : build.getWorkspace().list(this.war)) {
if(!adapter.redeploy(warFile,contextPath,build,launcher,listener))
@@ -51,6 +58,10 @@ public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListene

return true;
}

public String expandVariable(VariableResolver<String> variableResolver, EnvVars envVars, String variable) {
return Util.replaceMacro(envVars.expand(variable), variableResolver);
}

public BuildStepMonitor getRequiredMonitorService() {
return BuildStepMonitor.BUILD;

0 comments on commit ce2fc7f

Please sign in to comment.
You can’t perform that action at this time.