Example usage for javax.net.ssl SSLPeerUnverifiedException printStackTrace

List of usage examples for javax.net.ssl SSLPeerUnverifiedException printStackTrace

Introduction

In this page you can find the example usage for javax.net.ssl SSLPeerUnverifiedException printStackTrace.

Prototype

public void printStackTrace(PrintStream s) 

Source Link

Document

Prints this throwable and its backtrace to the specified print stream.

Usage

From source file:org.jenkinsci.plugins.stashNotifier.StashNotifier.java

/**
 * Processes the Jenkins events triggered before and after the build and
 * initiates the Stash notification.//  w  w w.  j  a va  2  s . c  o m
 * 
 * @param build      the build to notify Stash of
 * @param listener   the Jenkins build listener
 * @param state      the state of the build (in progress, success, failed)
 * @return         always true in order not to abort the Job in case of
 *                notification failures
 */
private boolean processJenkinsEvent(final AbstractBuild<?, ?> build, final BuildListener listener,
        final StashBuildState state) {

    PrintStream logger = listener.getLogger();

    // exit if Jenkins root URL is not configured. Stash build API 
    // requires valid link to build in CI system.
    if (Jenkins.getInstance().getRootUrl() == null) {
        logger.println("Cannot notify Stash! (Jenkins Root URL not configured)");
        return true;
    }

    String commitSha1 = lookupCommitSha1(build, listener);
    if (commitSha1 != null) {
        try {
            NotificationResult result = notifyStash(logger, build, commitSha1, listener, state);
            if (result.indicatesSuccess) {
                logger.println("Notified Stash for commit with id " + commitSha1);
            } else {
                logger.println("Failed to notify Stash for commit " + commitSha1 + " (" + result.message + ")");
            }
        } catch (SSLPeerUnverifiedException e) {
            logger.println("SSLPeerUnverifiedException caught while "
                    + "notifying Stash. Make sure your SSL certificate on "
                    + "your Stash server is valid or check the "
                    + " 'Ignore unverifiable SSL certificate' checkbox in the "
                    + "Stash plugin configuration of this job.");
        } catch (Exception e) {
            logger.println("Caught exception while notifying Stash with id " + commitSha1);
            e.printStackTrace(logger);
        }
    } else {
        logger.println("found no commit info");
    }
    return true;
}

From source file:org.jenkinsci.plugins.bitbucketNotifier.BitbucketNotifier.java

/**
 * Processes the Jenkins events triggered before and after the build and
 * initiates the Bitbucket notification.
 *
 * @param build      the build to notify Bitbucket of
 * @param listener   the Jenkins build listener
 * @param state      the state of the build (in progress, success, failed)
 * @return         always true in order not to abort the Job in case of
 *                notification failures//from  www .  jav a  2  s .  com
 */
private boolean processJenkinsEvent(final AbstractBuild<?, ?> build, final BuildListener listener,
        final BitbucketBuildState state) {

    PrintStream logger = listener.getLogger();

    // exit if Jenkins root URL is not configured. Bitbucket build API
    // requires valid link to build in CI system.
    if (Jenkins.getInstance().getRootUrl() == null) {
        logger.println("Cannot notify Bitbucket! (Jenkins Root URL not configured)");
        return true;
    }

    Collection<String> commitSha1s = lookupCommitSha1s(build, listener);
    for (String commitSha1 : commitSha1s) {
        try {
            NotificationResult result = notifyBitbucket(logger, build, commitSha1, listener, state);
            if (result.indicatesSuccess) {
                logger.println("Notified Bitbucket for commit with id " + commitSha1);
            } else {
                logger.println(
                        "Failed to notify Bitbucket for commit " + commitSha1 + " (" + result.message + ")");
            }
        } catch (SSLPeerUnverifiedException e) {
            logger.println("SSLPeerUnverifiedException caught while "
                    + "notifying Bitbucket. Make sure your SSL certificate on "
                    + "your Bitbucket server is valid or check the "
                    + " 'Ignore unverifiable SSL certificate' checkbox in the "
                    + "Bitbucket plugin configuration of this job.");
        } catch (Exception e) {
            logger.println("Caught exception while notifying Bitbucket with id " + commitSha1);
            e.printStackTrace(logger);
        }
    }
    if (commitSha1s.isEmpty()) {
        logger.println("found no commit info");
    }
    return true;
}