本文整理了Java中hudson.FilePath.unzip()
方法的一些代码示例,展示了FilePath.unzip()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FilePath.unzip()
方法的具体详情如下:
包路径:hudson.FilePath
类名称:FilePath
方法名:unzip
[英]When this FilePath represents a zip file, extracts that zip file.
[中]当此文件路径表示zip文件时,将提取该zip文件。
代码示例来源:origin: jenkinsci/jenkins
private void unzip(File dir, InputStream in) throws IOException {
File tmpFile = File.createTempFile("tmpzip", null); // uses java.io.tmpdir
try {
// TODO why does this not simply use ZipInputStream?
IOUtils.copy(in, tmpFile);
unzip(dir,tmpFile);
}
finally {
tmpFile.delete();
}
}
代码示例来源:origin: jenkinsci/jenkins
public void restoreTo(AbstractBuild<?,?> owner, FilePath dst, TaskListener listener) throws IOException, InterruptedException {
File zip = new File(owner.getRootDir(),"workspace.zip");
if (zip.exists()) {// we used to keep it in zip
new FilePath(zip).unzip(dst);
} else {// but since 1.456 we do tgz
File tgz = new File(owner.getRootDir(),"workspace.tgz");
new FilePath(tgz).untar(dst, TarCompression.GZIP);
}
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
private void unzip(File dir, InputStream in) throws IOException {
File tmpFile = File.createTempFile("tmpzip", null); // uses java.io.tmpdir
try {
// TODO why does this not simply use ZipInputStream?
IOUtils.copy(in, tmpFile);
unzip(dir,tmpFile);
}
finally {
tmpFile.delete();
}
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
public void restoreTo(AbstractBuild<?,?> owner, FilePath dst, TaskListener listener) throws IOException, InterruptedException {
File wss = new File(owner.getRootDir(),"workspace.zip");
new FilePath(wss).unzip(dst);
}
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
public void restoreTo(AbstractBuild<?,?> owner, FilePath dst, TaskListener listener) throws IOException, InterruptedException {
File wss = new File(owner.getRootDir(),"workspace.zip");
new FilePath(wss).unzip(dst);
}
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
public void restoreTo(AbstractBuild<?, ?> owner, FilePath dst, TaskListener listener) throws IOException, InterruptedException {
File wss = new File(owner.getRootDir(), "workspace.zip");
new FilePath(wss).unzip(dst);
}
}
代码示例来源:origin: hudson/hudson-2.x
public void restoreTo(AbstractBuild<?,?> owner, FilePath dst, TaskListener listener) throws IOException, InterruptedException {
File wss = new File(owner.getRootDir(),"workspace.zip");
new FilePath(wss).unzip(dst);
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
public void restoreTo(AbstractBuild<?,?> owner, FilePath dst, TaskListener listener) throws IOException, InterruptedException {
File zip = new File(owner.getRootDir(),"workspace.zip");
if (zip.exists()) {// we used to keep it in zip
new FilePath(zip).unzip(dst);
} else {// but since 1.456 we do tgz
File tgz = new File(owner.getRootDir(),"workspace.tgz");
new FilePath(tgz).untar(dst, TarCompression.GZIP);
}
}
}
代码示例来源:origin: jenkinsci/jenkinsfile-runner
public File allocate() throws Exception {
File target = NEW.allocate();
if(source.getProtocol().equals("file")) {
File src = new File(source.toURI());
if(src.isDirectory())
new FilePath(src).copyRecursiveTo("**/*",new FilePath(target));
else
if(src.getName().endsWith(".zip"))
new FilePath(src).unzip(new FilePath(target));
} else {
File tmp = File.createTempFile("hudson","zip");
try {
FileUtils.copyURLToFile(source,tmp);
new FilePath(tmp).unzip(new FilePath(target));
} finally {
tmp.delete();
}
}
return target;
}
}
代码示例来源:origin: org.eclipse.hudson/hudson-test-framework
public File allocate() throws Exception {
File target = NEW.allocate();
if (source.getProtocol().equals("file")) {
File src = new File(source.toURI());
if (src.isDirectory()) {
new FilePath(src).copyRecursiveTo("**/*", new FilePath(target));
} else if (src.getName().endsWith(".zip")) {
new FilePath(src).unzip(new FilePath(target));
}
} else {
File tmp = File.createTempFile("hudson", "zip");
try {
FileUtils.copyURLToFile(source, tmp);
new FilePath(tmp).unzip(new FilePath(target));
} finally {
tmp.delete();
}
}
return target;
}
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-test-harness
public File allocate() throws Exception {
File target = NEW.allocate();
if(source.getProtocol().equals("file")) {
File src = new File(source.toURI());
if(src.isDirectory())
new FilePath(src).copyRecursiveTo("**/*",new FilePath(target));
else
if(src.getName().endsWith(".zip"))
new FilePath(src).unzip(new FilePath(target));
} else {
File tmp = File.createTempFile("hudson","zip");
try {
FileUtils.copyURLToFile(source,tmp);
new FilePath(tmp).unzip(new FilePath(target));
} finally {
tmp.delete();
}
}
return target;
}
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-test-framework
public File allocate() throws Exception {
File target = NEW.allocate();
if(source.getProtocol().equals("file")) {
File src = new File(source.toURI());
if(src.isDirectory())
new FilePath(src).copyRecursiveTo("**/*",new FilePath(target));
else
if(src.getName().endsWith(".zip"))
new FilePath(src).unzip(new FilePath(target));
} else {
File tmp = File.createTempFile("hudson","zip");
try {
FileUtils.copyURLToFile(source,tmp);
new FilePath(tmp).unzip(new FilePath(target));
} finally {
tmp.delete();
}
}
return target;
}
}
代码示例来源:origin: io.jenkins.jenkinsfile-runner/setup
public File allocate() throws Exception {
File target = NEW.allocate();
if(source.getProtocol().equals("file")) {
File src = new File(source.toURI());
if(src.isDirectory())
new FilePath(src).copyRecursiveTo("**/*",new FilePath(target));
else
if(src.getName().endsWith(".zip"))
new FilePath(src).unzip(new FilePath(target));
} else {
File tmp = File.createTempFile("hudson","zip");
try {
FileUtils.copyURLToFile(source,tmp);
new FilePath(tmp).unzip(new FilePath(target));
} finally {
tmp.delete();
}
}
return target;
}
}
代码示例来源:origin: jenkinsci/jenkins-test-harness
public File allocate() throws Exception {
File target = NEW.allocate();
if(source.getProtocol().equals("file")) {
File src = new File(source.toURI());
if(src.isDirectory())
new FilePath(src).copyRecursiveTo("**/*",new FilePath(target));
else
if(src.getName().endsWith(".zip"))
new FilePath(src).unzip(new FilePath(target));
} else {
File tmp = File.createTempFile("hudson","zip");
try {
FileUtils.copyURLToFile(source,tmp);
new FilePath(tmp).unzip(new FilePath(target));
} finally {
tmp.delete();
}
}
return target;
}
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-test-harness
/**
* Extracts Ant and configures it.
*/
protected Ant.AntInstallation configureDefaultAnt() throws Exception {
Ant.AntInstallation antInstallation;
if (System.getenv("ANT_HOME") != null) {
antInstallation = new AntInstallation("default", System.getenv("ANT_HOME"), NO_PROPERTIES);
} else {
LOGGER.warning("Extracting a copy of Ant bundled in the test harness. " +
"To avoid a performance hit, set the environment variable ANT_HOME to point to an Ant installation.");
FilePath ant = hudson.getRootPath().createTempFile("ant", "zip");
ant.copyFrom(HudsonTestCase.class.getClassLoader().getResource("apache-ant-1.8.1-bin.zip"));
File antHome = createTmpDir();
ant.unzip(new FilePath(antHome));
// TODO: switch to tar that preserves file permissions more easily
if(!Functions.isWindows())
GNUCLibrary.LIBC.chmod(new File(antHome,"apache-ant-1.8.1/bin/ant").getPath(),0755);
antInstallation = new AntInstallation("default", new File(antHome,"apache-ant-1.8.1").getAbsolutePath(),NO_PROPERTIES);
}
hudson.getDescriptorByType(Ant.DescriptorImpl.class).setInstallations(antInstallation);
return antInstallation;
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-test-framework
/**
* Extracts Ant and configures it.
*/
protected Ant.AntInstallation configureDefaultAnt() throws Exception {
Ant.AntInstallation antInstallation;
if (System.getenv("ANT_HOME") != null) {
antInstallation = new AntInstallation("default", System.getenv("ANT_HOME"), NO_PROPERTIES);
} else {
LOGGER.warning("Extracting a copy of Ant bundled in the test harness. " +
"To avoid a performance hit, set the environment variable ANT_HOME to point to an Ant installation.");
FilePath ant = hudson.getRootPath().createTempFile("ant", "zip");
ant.copyFrom(HudsonTestCase.class.getClassLoader().getResource("apache-ant-1.8.1-bin.zip"));
File antHome = createTmpDir();
ant.unzip(new FilePath(antHome));
// TODO: switch to tar that preserves file permissions more easily
if(!Functions.isWindows())
GNUCLibrary.LIBC.chmod(new File(antHome,"apache-ant-1.8.1/bin/ant").getPath(),0755);
antInstallation = new AntInstallation("default", new File(antHome,"apache-ant-1.8.1").getAbsolutePath(),NO_PROPERTIES);
}
hudson.getDescriptorByType(Ant.DescriptorImpl.class).setInstallations(antInstallation);
return antInstallation;
}
代码示例来源:origin: org.eclipse.hudson/hudson-test-framework
/**
* Extracts Ant and configures it.
*/
protected Ant.AntInstallation configureDefaultAnt() throws Exception {
Ant.AntInstallation antInstallation;
if (System.getenv("ANT_HOME") != null) {
antInstallation = new AntInstallation("default", System.getenv("ANT_HOME"), NO_PROPERTIES);
} else {
LOGGER.warning("Extracting a copy of Ant bundled in the test harness. "
+ "To avoid a performance hit, set the environment variable ANT_HOME to point to an Ant installation.");
FilePath ant = hudson.getRootPath().createTempFile("ant", "zip");
ant.copyFrom(HudsonTestCase.class.getClassLoader().getResource("apache-ant-1.8.1-bin.zip"));
File antHome = createTmpDir();
ant.unzip(new FilePath(antHome));
// TODO: switch to tar that preserves file permissions more easily
if (!Functions.isWindows()) {
Util.chmod(new File(antHome, "apache-ant-1.8.1/bin/ant"), 0755);
}
antInstallation = new AntInstallation("default", new File(antHome, "apache-ant-1.8.1").getAbsolutePath(), NO_PROPERTIES);
}
hudson.getDescriptorByType(Ant.DescriptorImpl.class).setInstallations(antInstallation);
return antInstallation;
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-test-harness
mvn.copyFrom(HudsonTestCase.class.getClassLoader().getResource(mavenVersion + "-bin.zip"));
File mvnHome = new File(buildDirectory);//createTmpDir();
mvn.unzip(new FilePath(mvnHome));
代码示例来源:origin: org.jvnet.hudson.main/hudson-test-framework
mvn.copyFrom(HudsonTestCase.class.getClassLoader().getResource(mavenVersion + "-bin.zip"));
File mvnHome = new File(buildDirectory);//createTmpDir();
mvn.unzip(new FilePath(mvnHome));
代码示例来源:origin: org.eclipse.hudson/hudson-test-framework
mvn.copyFrom(HudsonTestCase.class.getClassLoader().getResource(mavenVersion + "-bin.zip"));
File mvnHome = new File(buildDirectory);//createTmpDir();
mvn.unzip(new FilePath(mvnHome));
内容来源于网络,如有侵权,请联系作者删除!