本文整理了Java中hudson.FilePath.write()
方法的一些代码示例,展示了FilePath.write()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FilePath.write()
方法的具体详情如下:
包路径:hudson.FilePath
类名称:FilePath
方法名:write
[英]Writes to this file. If this file already exists, it will be overwritten. If the directory doesn't exist, it will be created.
[中]写入此文件。如果此文件已存在,将被覆盖。如果目录不存在,将创建它。
代码示例来源:origin: jenkinsci/jenkins
/**
* Replaces the content of this file by the data from the given {@link InputStream}.
*
* @since 1.293
*/
public void copyFrom(InputStream in) throws IOException, InterruptedException {
try (OutputStream os = write()) {
org.apache.commons.io.IOUtils.copy(in, os);
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Copies this file to the specified target.
*/
public void copyTo(FilePath target) throws IOException, InterruptedException {
try {
try (OutputStream out = target.write()) {
copyTo(out);
}
} catch (IOException e) {
throw new IOException("Failed to copy "+this+" to "+target,e);
}
}
代码示例来源:origin: jenkinsci/jenkins
public void zip(FilePath dst) throws IOException, InterruptedException {
try (OutputStream os = dst.write()) {
zip(os);
}
}
代码示例来源:origin: jenkinsci/jenkins
@VisibleForTesting
void save() throws IOException, InterruptedException {
try (OutputStream os = store.write()) {
props.store(os, "Credential store");
}
// try to protect this file from other users, if we can.
store.chmod(0600);
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Place the data from {@link FileItem} into the file location specified by this {@link FilePath} object.
*/
public void copyFrom(FileItem file) throws IOException, InterruptedException {
if(channel==null) {
try {
file.write(writing(new File(remote)));
} catch (IOException e) {
throw e;
} catch (Exception e) {
throw new IOException(e);
}
} else {
try (InputStream i = file.getInputStream();
OutputStream o = write()) {
org.apache.commons.io.IOUtils.copy(i,o);
}
}
}
代码示例来源:origin: jenkinsci/jenkins
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException {
FilePath expected = preferredLocation(tool, node);
Installable inst = getInstallable();
if(inst==null) {
log.getLogger().println("Invalid tool ID "+id);
return expected;
}
if (inst instanceof NodeSpecific) {
inst = (Installable) ((NodeSpecific) inst).forNode(node, log);
}
if(isUpToDate(expected,inst))
return expected;
if(expected.installIfNecessaryFrom(new URL(inst.url), log, "Unpacking " + inst.url + " to " + expected + " on " + node.getDisplayName())) {
expected.child(".timestamp").delete(); // we don't use the timestamp
FilePath base = findPullUpDirectory(expected);
if(base!=null && base!=expected)
base.moveAllChildrenTo(expected);
// leave a record for the next up-to-date check
expected.child(".installedFrom").write(inst.url,"UTF-8");
expected.act(new ZipExtractionInstaller.ChmodRecAPlusX());
}
return expected;
}
代码示例来源:origin: jenkinsci/jenkins
iapf.write(randomUUID + System.lineSeparator(), "UTF-8");
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Replaces the content of this file by the data from the given {@link InputStream}.
*
* @since 1.293
*/
public void copyFrom(InputStream in) throws IOException, InterruptedException {
try (OutputStream os = write()) {
org.apache.commons.io.IOUtils.copy(in, os);
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@VisibleForTesting
void save() throws IOException, InterruptedException {
try (OutputStream os = store.write()) {
props.store(os, "Credential store");
}
// try to protect this file from other users, if we can.
store.chmod(0600);
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
public void zip(FilePath dst) throws IOException, InterruptedException {
try (OutputStream os = dst.write()) {
zip(os);
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Copies this file to the specified target.
*/
public void copyTo(FilePath target) throws IOException, InterruptedException {
try {
try (OutputStream out = target.write()) {
copyTo(out);
}
} catch (IOException e) {
throw new IOException("Failed to copy "+this+" to "+target,e);
}
}
代码示例来源:origin: jenkinsci/jenkins-test-harness
@Override
public void checkout(Run<?,?> build, Launcher launcher, FilePath workspace, TaskListener listener, File changelogFile, SCMRevisionState baseline) throws IOException, InterruptedException {
listener.getLogger().println("Staging "+path);
OutputStream os = workspace.child(path).write();
IOUtils.write(contents, os);
os.close();
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-test-framework
@Override
public boolean checkout(AbstractBuild build, Launcher launcher, FilePath workspace, BuildListener listener, File changeLogFile) throws IOException, InterruptedException {
listener.getLogger().println("Staging "+path);
OutputStream os = workspace.child(path).write();
IOUtils.write(contents, os);
os.close();
return true;
}
代码示例来源:origin: org.eclipse.hudson/hudson-test-framework
@Override
public boolean checkout(AbstractBuild build, Launcher launcher, FilePath workspace, BuildListener listener, File changeLogFile) throws IOException, InterruptedException {
listener.getLogger().println("Staging " + path);
OutputStream os = workspace.child(path).write();
IOUtils.write(contents, os);
os.close();
return true;
}
代码示例来源:origin: jenkinsci/jenkins-test-harness
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
listener.getLogger().println("Creating a file " + fileName);
FilePath workspace = build.getWorkspace();
if (workspace == null) {
throw new AbortException("Cannot get the workspace of the build");
}
workspace.child(fileName).write(fileContent, "UTF-8");
return true;
}
代码示例来源:origin: jenkinsci/kubernetes-cd-plugin
private FilePath fetchConfig(FilePath workspace) throws Exception {
SSHClient sshClient = new SSHClient(host, port, credentials);
try (SSHClient ignore = sshClient.connect()) {
FilePath configFile = workspace.createTempFile(Constants.KUBECONFIG_PREFIX, "");
try (OutputStream out = configFile.write()) {
sshClient.copyFrom(Constants.KUBECONFIG_FILE, out);
}
return configFile;
}
}
}
代码示例来源:origin: uber/phabricator-jenkins-plugin
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws
InterruptedException, IOException {
build.getWorkspace().child(fileName).write(content, "UTF-8");
return true;
}
};
代码示例来源:origin: uber/phabricator-jenkins-plugin
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws
InterruptedException, IOException {
build.getWorkspace().child(fileName).write(content, "UTF-8");
return true;
}
};
代码示例来源:origin: jenkinsci/marathon-plugin
@Override
public MarathonBuilder toFile(final String filename) throws InterruptedException, IOException, MarathonFileInvalidException {
final String realFilename = filename != null ? filename : MarathonBuilderUtils.MARATHON_RENDERED_JSON;
final FilePath renderedFilepath = workspace.child(Util.replaceMacro(realFilename, envVars));
if (renderedFilepath.exists() && renderedFilepath.isDirectory())
throw new MarathonFileInvalidException("File '" + realFilename + "' is a directory; not overwriting.");
renderedFilepath.write(json.toString(), null);
return this;
}
代码示例来源:origin: jenkinsci/workflow-cps-plugin
@Override public void evaluate() throws Throwable {
WorkflowJob p = jenkins.getItemByFullName("p", WorkflowJob.class);
WorkflowRun b = p.getBuildByNumber(2);
SemaphoreStep.success("wait/1", null);
story.j.assertLogContains("a ran on value from b", story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b)));
// Better case:
jenkins.getWorkspaceFor(p).child("b.groovy").write("def m(a, arg) {a(\"${arg} from b\")}; this", null);
p.setDefinition(new CpsFlowDefinition("def a; def b; node {a = load 'a.groovy'; b = load 'b.groovy'}; b.m(a, 'value')", true));
story.j.assertLogContains("a ran on value from b", story.j.assertBuildStatusSuccess(p.scheduleBuild2(0)));
}
});
内容来源于网络,如有侵权,请联系作者删除!