本文整理汇总了Java中jetbrains.buildServer.util.FileUtil.writeFileAndReportErrors方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.writeFileAndReportErrors方法的具体用法?Java FileUtil.writeFileAndReportErrors怎么用?Java FileUtil.writeFileAndReportErrors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jetbrains.buildServer.util.FileUtil
的用法示例。
在下文中一共展示了FileUtil.writeFileAndReportErrors方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: should_run_simple_command_file_ps1
import jetbrains.buildServer.util.FileUtil; //导入方法依赖的package包/类
@Test(dataProvider = "supportedBitnessProvider")
@TestFor(issues = "TW-29803")
public void should_run_simple_command_file_ps1(@NotNull final PowerShellBitness bits) throws Throwable {
final File dir = createTempDir();
final File code = new File(dir, "code.ps1");
FileUtil.writeFileAndReportErrors(code, "echo works");
setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.PS1.getValue());
setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.FILE.getValue());
setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_FILE, code.getPath());
setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bits.getValue());
final SFinishedBuild build = doTest(null);
dumpBuildLogLocally(build);
Assert.assertTrue(build.getBuildStatus().isSuccessful());
Assert.assertTrue(getBuildLog(build).contains("works"));
}
示例2: testOutputIsWrittenFromScriptInFile
import jetbrains.buildServer.util.FileUtil; //导入方法依赖的package包/类
@Test(dataProvider = "supportedBitnessProvider")
@TestFor(issues = "TW-34775")
public void testOutputIsWrittenFromScriptInFile(@NotNull final PowerShellBitness bits) throws Throwable {
final File dir = createTempDir();
final File code = new File(dir, "code.ps1");
FileUtil.writeFileAndReportErrors(code,
"param ([string]$PowerShellParam = \"value\",)\n" +
"Write-Host \"String from Write-Host\"\n" +
"Write-Output \"String from Write-Output\"\n" +
"Write-Host \"Function call from Write-Host $((Get-Date -Year 2000 -Month 12 -Day 31).DayOfYear)\"\n" +
"Write-Output \"Function call from Write-Output $((Get-Date -Year 2000 -Month 12 -Day 31).DayOfYear)\"\n"
);
setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.STDIN.getValue());
setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.FILE.getValue());
setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_FILE, code.getPath());
setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bits.getValue());
final SFinishedBuild build = doTest(null);
dumpBuildLogLocally(build);
Assert.assertTrue(build.getBuildStatus().isSuccessful());
Assert.assertTrue(getBuildLog(build).contains("String from Write-Host"));
Assert.assertTrue(getBuildLog(build).contains("String from Write-Output"));
Assert.assertTrue(getBuildLog(build).contains("Function call from Write-Host 366"));
Assert.assertTrue(getBuildLog(build).contains("Function call from Write-Output 366"));
}
示例3: getCustomScriptExecutable
import jetbrains.buildServer.util.FileUtil; //导入方法依赖的package包/类
private String getCustomScriptExecutable(AnsibleRunConfig config) throws RunBuildException {
String content = null;
File scriptFile = null;
if (config.getSourceCode() != null) {
content = config.getSourceCode().replace("\r\n", "\n").replace("\r", "\n");
}
if (StringUtil.isEmptyOrSpaces(content)) {
throw new RunBuildException("Custom script source code cannot be empty");
}
try {
scriptFile = File.createTempFile("ansible_custom_exe", null, getBuildTempDirectory());
FileUtil.writeFileAndReportErrors(scriptFile, content);
} catch (IOException e) {
throw new RunBuildException("Failed to create a tmp file for custom ansible execution script");
}
boolean executable = scriptFile.setExecutable(true, true);
if (!executable) {
throw new RunBuildException("Failed to set executable permissions to " + scriptFile.getAbsolutePath());
}
return scriptFile.getAbsolutePath();
}
示例4: VmwareCloudImage
import jetbrains.buildServer.util.FileUtil; //导入方法依赖的package包/类
public VmwareCloudImage(@NotNull final VMWareApiConnector apiConnector,
@NotNull final VmwareCloudImageDetails imageDetails,
@NotNull final CloudAsyncTaskExecutor asyncTaskExecutor,
@NotNull final File idxStorage,
@NotNull final CloudProfile profile) {
super(imageDetails.getSourceId(), imageDetails.getSourceId());
myImageDetails = imageDetails;
myApiConnector = apiConnector;
myAsyncTaskExecutor = asyncTaskExecutor;
myProfile = profile;
myActualSourceState = new AtomicReference<>();
myIdxFile = new File(idxStorage, imageDetails.getSourceId() + ".idx");
if (!myIdxFile.exists()){
try {
FileUtil.writeFileAndReportErrors(myIdxFile, "1");
} catch (IOException e) {
LOG.warn(String.format("Unable to write idx file '%s': %s", myIdxFile.getAbsolutePath(), e.toString()));
}
}
}
示例5: generateNixScriptFile
import jetbrains.buildServer.util.FileUtil; //导入方法依赖的package包/类
@NotNull
private File generateNixScriptFile(@NotNull final String argumentsToGenerate) throws RunBuildException {
final File script;
try {
script = FileUtil.createTempFile(getBuildTempDirectory(), "powershell_gen_" + System.currentTimeMillis(), ".sh", true);
myFilesToRemove.add(script);
FileUtil.writeFileAndReportErrors(script, argumentsToGenerate);
} catch (IOException e) {
throw new RunBuildException("Failed to generate .sh wrapper file");
}
return script;
}
示例6: generateRunScriptArguments
import jetbrains.buildServer.util.FileUtil; //导入方法依赖的package包/类
@NotNull
private List<String> generateRunScriptArguments(@NotNull final String argumentsToGenerate) throws RunBuildException {
final File bat;
try {
bat = FileUtil.createTempFile(getBuildTempDirectory(), "powershell", ".bat", true);
myFilesToRemove.add(bat);
FileUtil.writeFileAndReportErrors(bat, "@" + argumentsToGenerate);
} catch (IOException e) {
throw new RunBuildException("Failed to generate .bat file");
}
return Arrays.asList("/c", bat.getPath());
}
示例7: generateNewVmName
import jetbrains.buildServer.util.FileUtil; //导入方法依赖的package包/类
protected String generateNewVmName() {
int nextIdx;
try {
nextIdx = Integer.parseInt(FileUtil.readText(myIdxFile));
FileUtil.writeFileAndReportErrors(myIdxFile, String.valueOf(nextIdx + 1));
} catch (Exception e) {
LOG.warn("Will generate random clone index. Reason: unable to read idx file: " + e.toString());
Random r = new Random();
nextIdx = 100000 + r.nextInt(100000);
}
final String newVmName = String.format("%s-%d", getId(), nextIdx);
LOG.info("Will create a new VM with name " + newVmName);
return newVmName;
}