Skip to content
Permalink
Browse files

[JENKINS-27152] Use a temporary directory for managed files near the …

…workspace.
  • Loading branch information
jglick committed Feb 25, 2016
1 parent 6a68286 commit eb67346e042b09a535ca7e343a5e563706a19e79
Showing with 5 additions and 18 deletions.
  1. +5 −18 src/main/java/org/jenkinsci/plugins/configfiles/buildwrapper/ManagedFileUtil.java
@@ -26,18 +26,14 @@ of this software and associated documentation files (the "Software"), to deal
import hudson.AbortException;
import hudson.FilePath;
import hudson.model.AbstractBuild;
import hudson.remoting.VirtualChannel;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.jenkinsci.lib.configprovider.ConfigProvider;
import org.jenkinsci.lib.configprovider.model.Config;
import org.jenkinsci.plugins.configfiles.maven.security.CredentialsHelper;
import org.jenkinsci.plugins.configfiles.maven.security.HasServerCredentialMappings;
@@ -47,22 +43,13 @@ of this software and associated documentation files (the "Software"), to deal
import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials;
import hudson.model.Run;
import hudson.model.TaskListener;
import jenkins.security.MasterToSlaveCallable;
import hudson.slaves.WorkspaceList;

public class ManagedFileUtil {

/**
* Seems to be like {@link FilePath#createTempFile}, but passing the 2-arg form to File to use {@code ${java.io.tmpdir}}.
*/
public static FilePath createTempFile(VirtualChannel channel) throws IOException, InterruptedException {
return channel.call(new MasterToSlaveCallable<FilePath, IOException>() {
public FilePath call() throws IOException {
final File tmpTarget = File.createTempFile("config", "tmp");
return new FilePath(tmpTarget);
}

private static final long serialVersionUID = 1L;
});
// TODO move to WorkspaceList
private static FilePath tempDir(FilePath ws) {
return ws.sibling(ws.getName() + System.getProperty(WorkspaceList.class.getName(), "@") + "tmp");
}

/**
@@ -95,7 +82,7 @@ public FilePath call() throws IOException {

FilePath target;
if (createTempFile) {
target = ManagedFileUtil.createTempFile(workspace.getChannel());
target = tempDir(workspace).createTempFile("config", "tmp");
} else {

String expandedTargetLocation = managedFile.targetLocation;

0 comments on commit eb67346

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