hudson.Util.displayIOException()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(12.4k)|赞(0)|评价(0)|浏览(216)

本文整理了Java中hudson.Util.displayIOException()方法的一些代码示例,展示了Util.displayIOException()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.displayIOException()方法的具体详情如下:
包路径:hudson.Util
类名称:Util
方法名:displayIOException

Util.displayIOException介绍

[英]On Windows, error messages for IOException aren't very helpful. This method generates additional user-friendly error message to the listener
[中]在Windows上,IOException的错误消息没有多大帮助。此方法会向侦听器生成其他用户友好的错误消息

代码示例

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Handles a fatal build problem (exception) that occurred during the build.
  3. */
  4. private void handleFatalBuildProblem(@Nonnull BuildListener listener, @Nonnull Throwable e) {
  5. if(listener!=null) {
  6. LOGGER.log(FINE, getDisplayName()+" failed to build",e);
  7. if(e instanceof IOException)
  8. Util.displayIOException((IOException)e,listener);
  9. Functions.printStackTrace(e, listener.fatalError(e.getMessage()));
  10. } else {
  11. LOGGER.log(SEVERE, getDisplayName()+" failed to build and we don't even have a listener",e);
  12. }
  13. }

代码示例来源:origin: jenkinsci/jenkins

  1. script = createScriptFile(ws);
  2. } catch (IOException e) {
  3. Util.displayIOException(e,listener);
  4. Functions.printStackTrace(e, listener.fatalError(Messages.CommandInterpreter_UnableToProduceScript()));
  5. return false;
  6. Util.displayIOException(e, listener);
  7. Functions.printStackTrace(e, listener.fatalError(Messages.CommandInterpreter_CommandFailed()));
  8. Util.displayIOException(e,listener);
  9. Functions.printStackTrace(e, listener.fatalError(Messages.CommandInterpreter_UnableToDelete(script)));

代码示例来源:origin: jenkinsci/jenkins

  1. Util.displayIOException(e,listener);
  2. Functions.printStackTrace(e, listener.fatalError(Messages.Maven_ExecFailed()));
  3. return false;

代码示例来源:origin: org.jenkins-ci.plugins/rake

  1. public static boolean isAlreadyInstalled(RubyInstallation[] current, String path) {
  2. try {
  3. for (RubyInstallation ruby : current) {
  4. if (new File(ruby.getPath()).getCanonicalPath().equals(new File(path).getCanonicalPath())) {
  5. return true;
  6. }
  7. }
  8. } catch (IOException e) {
  9. hudson.Util.displayIOException(e, null);
  10. }
  11. return false;
  12. }

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

  1. /**
  2. * Handles a fatal build problem (exception) that occurred during the build.
  3. */
  4. private void handleFatalBuildProblem(BuildListener listener, Throwable e) {
  5. if(listener!=null) {
  6. if(e instanceof IOException)
  7. Util.displayIOException((IOException)e,listener);
  8. Writer w = listener.fatalError(e.getMessage());
  9. if(w!=null) {
  10. try {
  11. e.printStackTrace(new PrintWriter(w));
  12. w.close();
  13. } catch (IOException e1) {
  14. // ignore
  15. }
  16. }
  17. }
  18. }

代码示例来源:origin: org.eclipse.hudson/hudson-core

  1. /**
  2. * Handles a fatal build problem (exception) that occurred during the build.
  3. */
  4. private void handleFatalBuildProblem(BuildListener listener, Throwable e) {
  5. if (listener != null) {
  6. if (e instanceof IOException) {
  7. Util.displayIOException((IOException) e, listener);
  8. }
  9. Writer w = listener.fatalError(e.getMessage());
  10. if (w != null) {
  11. try {
  12. e.printStackTrace(new PrintWriter(w));
  13. w.close();
  14. } catch (IOException e1) {
  15. // ignore
  16. }
  17. }
  18. }
  19. }

代码示例来源:origin: hudson/hudson-2.x

  1. /**
  2. * Handles a fatal build problem (exception) that occurred during the build.
  3. */
  4. private void handleFatalBuildProblem(BuildListener listener, Throwable e) {
  5. if(listener!=null) {
  6. if(e instanceof IOException)
  7. Util.displayIOException((IOException)e,listener);
  8. Writer w = listener.fatalError(e.getMessage());
  9. if(w!=null) {
  10. try {
  11. e.printStackTrace(new PrintWriter(w));
  12. w.close();
  13. } catch (IOException e1) {
  14. // ignore
  15. }
  16. }
  17. }
  18. }

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

  1. /**
  2. * Handles a fatal build problem (exception) that occurred during the build.
  3. */
  4. private void handleFatalBuildProblem(BuildListener listener, Throwable e) {
  5. if(listener!=null) {
  6. if(e instanceof IOException)
  7. Util.displayIOException((IOException)e,listener);
  8. Writer w = listener.fatalError(e.getMessage());
  9. if(w!=null) {
  10. try {
  11. e.printStackTrace(new PrintWriter(w));
  12. w.close();
  13. } catch (IOException e1) {
  14. // ignore
  15. }
  16. }
  17. }
  18. }

代码示例来源:origin: org.jenkins-ci.plugins/rake

  1. protected static RubyInstallation[] getCanonicalRubies(RubyInstallation[] currentInstallations, Collection<File> candidates) {
  2. try {
  3. Collection<RubyInstallation> currentList = new LinkedHashSet<RubyInstallation>(Arrays.asList(currentInstallations));
  4. out: for (File ruby : candidates) {
  5. for (RubyInstallation current : currentList) {
  6. if (current.getCanonicalExecutable().equals(getExecutable(ruby.getCanonicalPath()).getCanonicalFile())) {
  7. continue out;
  8. }
  9. }
  10. currentList.add(new RubyInstallation(ruby.getName(), ruby.getCanonicalPath()));
  11. }
  12. return currentList.toArray(new RubyInstallation[currentList.size()]);
  13. } catch (IOException e) {
  14. hudson.Util.displayIOException(e, null);
  15. }
  16. return new RubyInstallation[0];
  17. }

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

  1. /**
  2. * Handles a fatal build problem (exception) that occurred during the build.
  3. */
  4. private void handleFatalBuildProblem(@Nonnull BuildListener listener, @Nonnull Throwable e) {
  5. if(listener!=null) {
  6. LOGGER.log(FINE, getDisplayName()+" failed to build",e);
  7. if(e instanceof IOException)
  8. Util.displayIOException((IOException)e,listener);
  9. Functions.printStackTrace(e, listener.fatalError(e.getMessage()));
  10. } else {
  11. LOGGER.log(SEVERE, getDisplayName()+" failed to build and we don't even have a listener",e);
  12. }
  13. }

代码示例来源:origin: org.jenkins-ci.plugins/rake

  1. public static RubyInstallation[] getCanonicalRubies(RubyInstallation[] currentInstallations) {
  2. try {
  3. Collection<File> rubies = getRubyInstallations();
  4. return getCanonicalRubies(currentInstallations, rubies);
  5. } catch (IOException e) {
  6. hudson.Util.displayIOException(e, null);
  7. }
  8. return new RubyInstallation[0];
  9. }

代码示例来源:origin: groupon/DotCi

  1. private boolean export(final AbstractBuild<?, ?> build, final TaskListener listener) throws InterruptedException, IOException {
  2. final FilePath ws = getFilePath(build);
  3. try {
  4. createFile(ws);
  5. } catch (final IOException e) {
  6. Util.displayIOException(e, listener);
  7. e.printStackTrace(listener.fatalError(Messages.CommandInterpreter_UnableToProduceScript()));
  8. throw e;
  9. }
  10. return true;
  11. }

代码示例来源:origin: SonarSource/sonar-scanner-jenkins

  1. private void handleErrors(TaskListener listener, @Nullable SonarRunnerInstallation sri, long startTime, IOException e) {
  2. Logger.printFailureMessage(listener);
  3. Util.displayIOException(e, listener);
  4. String errorMessage = Messages.SonarScanner_ExecFailed();
  5. if (sri == null && (System.currentTimeMillis() - startTime) < 1000 && getDescriptor().getSonarRunnerInstallations() == null) {
  6. // looks like the user didn't configure any SonarQube Scanner installation
  7. errorMessage += Messages.SonarScanner_GlobalConfigNeeded();
  8. }
  9. e.printStackTrace(listener.fatalError(errorMessage));
  10. }

代码示例来源:origin: jenkinsci/pipeline-maven-plugin

  1. @Override
  2. protected void finished(StepContext context) throws Exception {
  3. mavenSpyLogProcessor.processMavenSpyLogs(context, tempBinDir, options, mavenPublisherStrategy);
  4. try {
  5. tempBinDir.deleteRecursive();
  6. } catch (IOException | InterruptedException e) {
  7. BuildListener listener = context.get(BuildListener.class);
  8. try {
  9. if (e instanceof IOException) {
  10. Util.displayIOException((IOException) e, listener); // Better IOException display on windows
  11. }
  12. e.printStackTrace(listener.fatalError("Error deleting temporary files"));
  13. } catch (Throwable t) {
  14. t.printStackTrace();
  15. }
  16. }
  17. }

代码示例来源:origin: lacostej/jenkins-unity3d-plugin

  1. @Override
  2. public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException {
  3. try {
  4. _perform(build, launcher, listener);
  5. return true;
  6. } catch (PerformException e) {
  7. listener.fatalError(e.getMessage());
  8. return false;
  9. } catch (IOException e) {
  10. Util.displayIOException(e, listener);
  11. String errorMessage = Messages.Unity3d_ExecUnexpectedlyFailed();
  12. e.printStackTrace(listener.fatalError(errorMessage));
  13. return false;
  14. }
  15. }

代码示例来源:origin: jenkinsci/artifactory-plugin

  1. private boolean RunMaven(Run<?, ?> build, Launcher launcher, TaskListener listener, EnvVars env, FilePath workDir, String[] cmds) throws InterruptedException, IOException {
  2. try {
  3. int exitValue = launcher.launch().cmds(cmds).envs(env).stdout(listener).pwd(workDir).join();
  4. boolean success = (exitValue == 0);
  5. build.setResult(success ? Result.SUCCESS : Result.FAILURE);
  6. return success;
  7. } catch (IOException e) {
  8. Util.displayIOException(e, listener);
  9. e.printStackTrace(listener.fatalError("command execution failed"));
  10. return false;
  11. } finally {
  12. ActionableHelper.deleteFilePath(workDir, classworldsConfPath);
  13. }
  14. }

代码示例来源:origin: org.jenkins-ci.plugins/javadoc

  1. @Override public void perform(Run<?,?> build, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException, IOException {
  2. listener.getLogger().println(Messages.JavadocArchiver_Publishing());
  3. EnvVars env = build.getEnvironment(listener);
  4. FilePath javadoc = workspace.child(env.expand(javadocDir));
  5. FilePath target = new FilePath(keepAll ? getJavadocDir(build) : getJavadocDir(build.getParent()));
  6. try {
  7. if (javadoc.copyRecursiveTo("**/*",target)==0) {
  8. if(build.getResult().isBetterOrEqualTo(Result.UNSTABLE)) {
  9. // If the build failed, don't complain that there was no javadoc.
  10. // The build probably didn't even get to the point where it produces javadoc.
  11. listener.error(Messages.JavadocArchiver_NoMatchFound(javadoc,javadoc.validateAntFileMask("**/*")));
  12. }
  13. build.setResult(Result.FAILURE);
  14. return;
  15. }
  16. } catch (IOException e) {
  17. Util.displayIOException(e,listener);
  18. e.printStackTrace(listener.fatalError(Messages.JavadocArchiver_UnableToCopy(javadoc,target)));
  19. build.setResult(Result.FAILURE);
  20. return;
  21. }
  22. build.addAction(new JavadocBuildAction());
  23. }

代码示例来源:origin: org.jenkins-ci.plugins/cloverphp

  1. @Override
  2. public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
  3. throws InterruptedException {
  4. final File buildRootDir = build.getRootDir(); // should this top level?
  5. final FilePath cloverphpBuildTarget = new FilePath(buildRootDir).child("cloverphp");
  6. final FilePath workspace = build.getWorkspace();
  7. try {
  8. listener.getLogger().println("Publishing Clover coverage report...");
  9. // create "jobs/builds/XXX/cloverphp"
  10. cloverphpBuildTarget.mkdirs();
  11. EnvVars env = build.getEnvironment(listener);
  12. if (isPublishHtmlReport() && !isDisableArchiving()) {
  13. FilePath coverageReportDir = workspace.child(env.expand(reportDir));
  14. FilePath htmlReportDir = new FilePath(cloverphpBuildTarget, "htmlreport");
  15. htmlReportDir.mkdirs();
  16. final boolean htmlExists = copyHtmlReport(coverageReportDir, htmlReportDir, listener);
  17. if (htmlExists) {
  18. // only add the HTML build action, if the HTML report is available
  19. build.getActions().add(new CloverHtmlBuildAction(htmlReportDir));
  20. }
  21. }
  22. final boolean xmlExists = copyXmlReport(workspace, cloverphpBuildTarget, listener, env.expand(xmlLocation));
  23. processCloverXml(build, listener, cloverphpBuildTarget);
  24. } catch (IOException e) {
  25. Util.displayIOException(e, listener);
  26. build.setResult(Result.FAILURE);
  27. }
  28. return true;
  29. }

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

  1. public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
  2. listener.getLogger().println(Messages.JavadocArchiver_Publishing());
  3. EnvVars env = build.getEnvironment(listener);
  4. FilePath javadoc = build.getWorkspace().child(env.expand(javadocDir));
  5. FilePath target = new FilePath(keepAll ? getJavadocDir(build) : getJavadocDir(build.getProject()));
  6. try {
  7. if (javadoc.copyRecursiveTo("**/*",target)==0) {
  8. if(build.getResult().isBetterOrEqualTo(Result.UNSTABLE)) {
  9. // If the build failed, don't complain that there was no javadoc.
  10. // The build probably didn't even get to the point where it produces javadoc.
  11. listener.error(Messages.JavadocArchiver_NoMatchFound(javadoc,javadoc.validateAntFileMask("**/*")));
  12. }
  13. build.setResult(Result.FAILURE);
  14. return true;
  15. }
  16. } catch (IOException e) {
  17. Util.displayIOException(e,listener);
  18. e.printStackTrace(listener.fatalError(Messages.JavadocArchiver_UnableToCopy(javadoc,target)));
  19. build.setResult(Result.FAILURE);
  20. return true;
  21. }
  22. // add build action, if javadoc is recorded for each build
  23. if(keepAll)
  24. build.addAction(new JavadocBuildAction(build));
  25. return true;
  26. }

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

  1. public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
  2. listener.getLogger().println(Messages.JavadocArchiver_Publishing());
  3. EnvVars env = build.getEnvironment(listener);
  4. FilePath javadoc = build.getWorkspace().child(env.expand(javadocDir));
  5. FilePath target = new FilePath(keepAll ? getJavadocDir(build) : getJavadocDir(build.getProject()));
  6. try {
  7. if (javadoc.copyRecursiveTo("**/*",target)==0) {
  8. if(build.getResult().isBetterOrEqualTo(Result.UNSTABLE)) {
  9. // If the build failed, don't complain that there was no javadoc.
  10. // The build probably didn't even get to the point where it produces javadoc.
  11. listener.error(Messages.JavadocArchiver_NoMatchFound(javadoc,javadoc.validateAntFileMask("**/*")));
  12. }
  13. build.setResult(Result.FAILURE);
  14. return true;
  15. }
  16. } catch (IOException e) {
  17. Util.displayIOException(e,listener);
  18. e.printStackTrace(listener.fatalError(Messages.JavadocArchiver_UnableToCopy(javadoc,target)));
  19. build.setResult(Result.FAILURE);
  20. return true;
  21. }
  22. // add build action, if javadoc is recorded for each build
  23. if(keepAll)
  24. build.addAction(new JavadocBuildAction(build));
  25. return true;
  26. }

相关文章