本文整理了Java中hudson.FilePath.readToString()
方法的一些代码示例,展示了FilePath.readToString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FilePath.readToString()
方法的具体详情如下:
包路径:hudson.FilePath
类名称:FilePath
方法名:readToString
[英]Reads this file into a string, by using the current system encoding.
[中]使用当前系统编码将此文件读入字符串。
代码示例来源:origin: jenkinsci/jenkins
/**
* Checks if the specified expected location already contains the installed version of the tool.
*
* This check needs to run fairly efficiently. The current implementation uses the source URL of {@link Installable},
* based on the assumption that released bits do not change its content.
*/
protected boolean isUpToDate(FilePath expectedLocation, Installable i) throws IOException, InterruptedException {
FilePath marker = expectedLocation.child(".installedFrom");
return marker.exists() && marker.readToString().equals(i.url);
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Determines if the security settings seem to match the defaults. Here, we only
* really care about and test for HudsonPrivateSecurityRealm and the user setup.
* Other settings are irrelevant.
*/
/*package*/ boolean isUsingSecurityDefaults() {
Jenkins j = Jenkins.get();
if (j.getSecurityRealm() instanceof HudsonPrivateSecurityRealm) {
HudsonPrivateSecurityRealm securityRealm = (HudsonPrivateSecurityRealm)j.getSecurityRealm();
try {
if(securityRealm.getAllUsers().size() == 1) {
HudsonPrivateSecurityRealm.Details details = securityRealm.loadUserByUsername(SetupWizard.initialSetupAdminUserName);
FilePath iapf = getInitialAdminPasswordFile();
if (iapf.exists()) {
if (details.isPasswordCorrect(iapf.readToString().trim())) {
return true;
}
}
}
} catch(UsernameNotFoundException | IOException | InterruptedException e) {
return false; // Not initial security setup if no transitional admin user / password found
}
}
return false;
}
代码示例来源:origin: jenkinsci/jenkins
public Authentication authenticate() throws AuthenticationException, IOException, InterruptedException {
if (userName==null)
return command.getTransportAuthentication(); // no authentication parameter. fallback to the transport
if (passwordFile!=null)
try {
password = new FilePath(command.checkChannel(), passwordFile).readToString().trim();
} catch (IOException e) {
throw new BadCredentialsException("Failed to read "+passwordFile,e);
}
if (password==null)
password = command.checkChannel().call(new InteractivelyAskForPassword());
if (password==null)
throw new BadCredentialsException("No password specified");
UserDetails d = doAuthenticate(userName, password);
return new UsernamePasswordAuthenticationToken(d, password, d.getAuthorities());
}
};
代码示例来源:origin: jenkinsci/jenkins
String setupKey = iapf.readToString().trim();
String ls = System.lineSeparator();
LOGGER.info(ls + ls + "*************************************************************" + ls
代码示例来源:origin: jenkinsci/log-parser-plugin
public static String[] readParsingRules(final FilePath parsingRulesFile) throws IOException {
try {
return parsingRulesFile.readToString().split("\n");
} catch (InterruptedException ie) {
throw new IOException(ie);
}
}
代码示例来源:origin: jenkinsci/pipeline-aws-plugin
private String readTemplateFile(StepExecution stepExecution) {
if (this.file == null) {
return null;
}
try {
FilePath child = loadFileFromWorkspace(stepExecution, this.file);
return child.readToString();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Checks if the specified expected location already contains the installed version of the tool.
*
* This check needs to run fairly efficiently. The current implementation uses the source URL of {@link Installable},
* based on the assumption that released bits do not change its content.
*/
protected boolean isUpToDate(FilePath expectedLocation, Installable i) throws IOException, InterruptedException {
FilePath marker = expectedLocation.child(".installedFrom");
return marker.exists() && marker.readToString().equals(i.url);
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
/**
* Checks if the specified expected location already contains the installed
* version of the tool.
*
* This check needs to run fairly efficiently. The current implementation
* uses the souce URL of {@link Installable}, based on the assumption that
* released bits do not change its content.
*/
protected boolean isUpToDate(FilePath expectedLocation, Installable i) throws IOException, InterruptedException {
FilePath marker = expectedLocation.child(".installedFrom");
return marker.exists() && marker.readToString().equals(i.url);
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
/**
* Checks if the specified expected location already contains the installed version of the tool.
*
* This check needs to run fairly efficiently. The current implementation uses the souce URL of {@link Installable},
* based on the assumption that released bits do not change its content.
*/
protected boolean isUpToDate(FilePath expectedLocation, Installable i) throws IOException, InterruptedException {
FilePath marker = expectedLocation.child(".installedFrom");
return marker.exists() && marker.readToString().equals(i.url);
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
/**
* Checks if the specified expected location already contains the installed version of the tool.
*
* This check needs to run fairly efficiently. The current implementation uses the souce URL of {@link Installable},
* based on the assumption that released bits do not change its content.
*/
protected boolean isUpToDate(FilePath expectedLocation, Installable i) throws IOException, InterruptedException {
FilePath marker = expectedLocation.child(".installedFrom");
return marker.exists() && marker.readToString().equals(i.url);
}
代码示例来源:origin: hudson/hudson-2.x
/**
* Checks if the specified expected location already contains the installed version of the tool.
*
* This check needs to run fairly efficiently. The current implementation uses the souce URL of {@link Installable},
* based on the assumption that released bits do not change its content.
*/
protected boolean isUpToDate(FilePath expectedLocation, Installable i) throws IOException, InterruptedException {
FilePath marker = expectedLocation.child(".installedFrom");
return marker.exists() && marker.readToString().equals(i.url);
}
代码示例来源:origin: jenkinsci/nodejs-plugin
public static boolean areNpmPackagesUpToDate(FilePath expected, String npmPackages, long npmPackagesRefreshHours) throws IOException, InterruptedException {
FilePath marker = expected.child(NPM_PACKAGES_RECORD_FILENAME);
return marker.exists() && marker.readToString().equals(npmPackages) && System.currentTimeMillis() < marker.lastModified()+ TimeUnit.HOURS.toMillis(npmPackagesRefreshHours);
}
代码示例来源:origin: jenkinsci/pipeline-aws-plugin
private String readTemplate(String file) {
if (file == null || file.isEmpty()) {
return null;
}
try {
return this.getContext().get(FilePath.class).child(file).readToString();
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
}
代码示例来源:origin: jenkinsci/artifactory-plugin
public static String getSpecStringFromSpecConf(SpecConfiguration specConfiguration, EnvVars env, FilePath workspace, PrintStream logger)
throws IOException, InterruptedException {
if (StringUtils.isNotBlank(specConfiguration.getFilePath())) {
String filePath = specConfiguration.getFilePath().trim();
filePath = Util.replaceMacro(filePath, env);
String spec = buildDownloadSpecPath(filePath, workspace, logger).readToString();
return Util.replaceMacro(spec.trim(), env);
}
if (StringUtils.isNotBlank(specConfiguration.getSpec())) {
return Util.replaceMacro(specConfiguration.getSpec().trim(), env);
}
return "";
}
代码示例来源:origin: groupon/DotCi
private String getDotCiYml(final DynamicBuild build) throws IOException, InterruptedException {
final FilePath fp = new FilePath(build.getWorkspace(), ".ci.yml");
if (!fp.exists()) {
throw new InvalidBuildConfigurationException("No .ci.yml found.");
}
return fp.readToString();
}
代码示例来源:origin: jenkinsci/debian-package-builder-plugin
private FilePath getRemoteKeyPath(AbstractBuild<?, ?> build, Runner runner) throws IOException, InterruptedException {
String keysDir = "debian-package-builder-keys";
String relativeKeyPath = new File(keysDir, getRepo(build, runner).getKeypath()).getPath();
File absoluteKeyPath = new File (Jenkins.getInstance().getRootDir(), relativeKeyPath);
FilePath localKey = new FilePath(absoluteKeyPath);
FilePath remoteKey = build.getWorkspace().createTextTempFile("private", "key", localKey.readToString());
remoteKey.chmod(0600);
return remoteKey;
}
代码示例来源:origin: jenkinsci/pipeline-aws-plugin
@Override
protected Void run() throws Exception {
final String roleName = this.step.getRoleName();
final String policyFile = this.step.getPolicyFile();
Preconditions.checkArgument(roleName != null && !roleName.isEmpty(), "roleName must not be null or empty");
Preconditions.checkArgument(policyFile != null && !policyFile.isEmpty(), "policyFile must not be null or empty");
AmazonIdentityManagement iamClient = AWSClientFactory.create(AmazonIdentityManagementClientBuilder.standard(), Execution.this.getContext());
UpdateAssumeRolePolicyRequest request = new UpdateAssumeRolePolicyRequest();
request.withRoleName(roleName);
request.withPolicyDocument(Execution.this.getContext().get(FilePath.class).child(policyFile).readToString());
iamClient.updateAssumeRolePolicy(request);
Execution.this.getContext().get(TaskListener.class).getLogger().format("Updated trust policy of role %s %n", roleName);
return null;
}
代码示例来源:origin: jenkinsci/marathon-plugin
@Override
public MarathonBuilder read(final String filename) throws IOException, InterruptedException, MarathonFileMissingException, MarathonFileInvalidException {
final String realFilename = filename != null ? filename : MarathonBuilderUtils.MARATHON_JSON;
final FilePath marathonFile = workspace.child(realFilename);
if (!marathonFile.exists()) {
throw new MarathonFileMissingException(realFilename);
} else if (marathonFile.isDirectory()) {
throw new MarathonFileInvalidException("File '" + realFilename + "' is a directory.");
}
final String content = marathonFile.readToString();
this.json = JSONObject.fromObject(content);
return this;
}
代码示例来源:origin: jenkinsci/groovy-plugin
@Override
public SecureGroovyScript getSecureGroovyScript(FilePath projectWorkspace, AbstractBuild<?, ?> build, TaskListener listener) throws IOException, InterruptedException {
EnvVars env = build.getEnvironment(listener);
String expandedScriptFile = env.expand(this.scriptFile);
String text = new FilePath(projectWorkspace, expandedScriptFile).readToString();
return new SecureGroovyScript(text, true, null).configuring(ApprovalContext.create()/* unused but just in case: */.withItem(build.getParent()));
}
代码示例来源:origin: jenkinsci/mercurial-plugin
public void touchAndCommit(FilePath repo, String... names) throws Exception {
for (String name : names) {
FilePath toTouch = repo.child(name);
if (!toTouch.exists()) {
toTouch.getParent().mkdirs();
toTouch.touch(0);
hg(repo, "add", name);
} else {
toTouch.write(toTouch.readToString() + "extra line\n", "UTF-8");
}
}
hg(repo, "commit", "--message", "added " + Arrays.toString(names));
}
内容来源于网络,如有侵权,请联系作者删除!