Child pages
  • Amazon SNS Notifier
Skip to end of metadata
Go to start of metadata

View Amazon SNS Build Notifier on the plugin site for more information.

Send build notifications to an AWS SNS Topic.

From version 1.7 on you can customize the SNS subject and payload message making use of build and environment variables.

From version 1.8 you can set in the global configuration whether you want also to send out an SNS notification on build start.

10 Comments

  1. My install of this does not send SNS notifications. Instead, I see this in the logs after the build finishes. Note the times between the three log lines. Do I need a special port open?

    Jul 24, 2014 3:30:56 AM hudson.model.Run execute
    INFO: apixio-common #687 main build action completed: SUCCESS
    Jul 24, 2014 3:31:25 AM com.cloudbees.jenkins.GitHubRepositoryName create
    WARNING: Could not match URL git@github.com:/Apixio/common
    Jul 24, 2014 3:33:07 AM org.eclipse.jetty.util.log.JavaUtilLog warn
    WARNING:
    java.nio.channels.ClosedChannelException
        at sun.nio.ch.SocketChannelImpl.ensureWriteOpen(SocketChannelImpl.java:265)
        at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:474)
        at org.eclipse.jetty.io.nio.ChannelEndPoint.flush(ChannelEndPoint.java:293)
        at org.eclipse.jetty.io.nio.SelectChannelEndPoint.flush(SelectChannelEndPoint.java:402)
        at org.eclipse.jetty.io.nio.SslConnection.process(SslConnection.java:337)
        at org.eclipse.jetty.io.nio.SslConnection.access$900(SslConnection.java:48)
        at org.eclipse.jetty.io.nio.SslConnection$SslEndPoint.flush(SslConnection.java:738)
        at org.eclipse.jetty.io.nio.SslConnection$SslEndPoint.shutdownOutput(SslConnection.java:641)
        at org.eclipse.jetty.io.nio.SslConnection.onIdleExpired(SslConnection.java:260)
        at org.eclipse.jetty.io.nio.SelectChannelEndPoint.onIdleExpired(SelectChannelEndPoint.java:349)
        at org.eclipse.jetty.io.nio.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:326)
        at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)

    1. From the stacktrace this doesn't look specific to the the snsnotify plugin. Anyways did you figure out the problem, might it be related to a URL misconfiguration issue? 

  2. I'm getting the below error:

    I have apache commons logging package installed on the box. any ideas on how to resolve this?

    Aug 30, 2015 9:19:48 AM org.jenkinsci.plugins.snsnotify.AmazonSNSNotifier send
    INFO: Setup SNS client 'sns.us-west-2.amazonaws.com' ...
    Aug 30, 2015 9:19:48 AM hudson.model.listeners.RunListener report
    WARNING: RunListener failed
    java.lang.NoClassDefFoundError: Could not initialize class com.amazonaws.ClientConfiguration at com.amazonaws.services.sns.AmazonSNSClient.<init>(AmazonSNSClient.java:128) at org.jenkinsci.plugins.snsnotify.AmazonSNSNotifier.send(AmazonSNSNotifier.java:144) at org.jenkinsci.plugins.snsnotify.AmazonSNSNotifier.onCompleted(AmazonSNSNotifier.java:85) at org.jenkinsci.plugins.snsnotify.BuildListener.onCompleted(BuildListener.java:30) at org.jenkinsci.plugins.snsnotify.BuildListener.onCompleted(BuildListener.java:8) at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:199) at hudson.model.Run.execute(Run.java:1783) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:381Aug 30, 2015 9:19:48 AM org.jenkinsci.plugins.snsnotify.AmazonSNSNotifier send
    INFO: Setup SNS client 'sns.us-west-2.amazonaws.com' ...
    Aug 30, 2015 9:19:48 AM hudson.model.listeners.RunListener report
    WARNING: RunListener failed
    java.lang.NoClassDefFoundError: Could not initialize class com.amazonaws.ClientConfiguration
    at com.amazonaws.services.sns.AmazonSNSClient.<init>(AmazonSNSClient.java:128)
    at org.jenkinsci.plugins.snsnotify.AmazonSNSNotifier.send(AmazonSNSNotifier.java:144)
    at org.jenkinsci.plugins.snsnotify.AmazonSNSNotifier.onCompleted(AmazonSNSNotifier.java:85)
    at org.jenkinsci.plugins.snsnotify.BuildListener.onCompleted(BuildListener.java:30)
    at org.jenkinsci.plugins.snsnotify.BuildListener.onCompleted(BuildListener.java:8)
    at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:199)
    at hudson.model.Run.execute(Run.java:1783)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:381)

  3. I was having a problem getting SNS Notifier to send messages.  It was logging the following to /var/log/jenkins/jenkins.log:

    Oct 28, 2015 7:35:11 PM org.jenkinsci.plugins.snsnotify.AmazonSNSNotifier send
    INFO: Setup SNS client 'sns.us-east-1.amazonaws.com' ...
    Oct 28, 2015 7:35:11 PM hudson.model.listeners.RunListener report
    WARNING: RunListener failed
    java.lang.NoClassDefFoundError: org/apache/http/util/Args
            at org.apache.http.conn.scheme.Scheme.<init>(Scheme.java:90)
            at org.apache.http.impl.conn.SchemeRegistryFactory.createDefault(SchemeRegistryFactory.java:50)
            at com.amazonaws.http.ConnectionManagerFactory.createPoolingClientConnManager(ConnectionManagerFactory.java:29)
            at com.amazonaws.http.HttpClientFactory.createHttpClient(HttpClientFactory.java:104)
            at com.amazonaws.http.AmazonHttpClient.<init>(AmazonHttpClient.java:198)
            at com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:132)
            at com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:116)
            at com.amazonaws.services.sns.AmazonSNSClient.<init>(AmazonSNSClient.java:147)
            at com.amazonaws.services.sns.AmazonSNSClient.<init>(AmazonSNSClient.java:128)
            at org.jenkinsci.plugins.snsnotify.AmazonSNSNotifier.send(AmazonSNSNotifier.java:144)
            at org.jenkinsci.plugins.snsnotify.AmazonSNSNotifier.onCompleted(AmazonSNSNotifier.java:85)
            at org.jenkinsci.plugins.snsnotify.BuildListener.onCompleted(BuildListener.java:30)
            at org.jenkinsci.plugins.snsnotify.BuildListener.onCompleted(BuildListener.java:8)
            at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:201)
            at hudson.model.Run.execute(Run.java:1786)
            at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
            at hudson.model.ResourceController.execute(ResourceController.java:98)
            at hudson.model.Executor.run(Executor.java:408)
    

    It turns out the 1.9 comes packaged with multiple (different versioned) copies of certain libraries.  I deleted the duplicates and updated httpcore, then restarted Jenkins and now it's working great:

    My fix:

    $ cd /var/lib/jenkins/plugins/snsnotify/WEB-INF/lib/
    $ rm *-1.9.0.jar
    $ rm joda-time-2.5.jar jackson-databind-2.1.1.jar jackson-core-2.1.1.jar jackson-annotations-2.1.1.jar httpclient-4.2.5.jar
    $ rm httpcore-*.jar
    $ wget 'http://www.java2s.com/Code/JarDownload/httpcore/httpcore-4.3-beta1.jar.zip'
    $ unzip httpcore-4.3-beta1.jar.zip
    $ rm httpcore-4.3-beta1.jar.zip
    
  4. If anyone wants to utilize Roles instead of keys, just follow the instructions here: https://github.com/jenkinsci/snsnotify-plugin but modify the following after downloading, and before compiling.
    Edit snsnotify-plugin/src/main/java/org/jenkinsci/plugins/snsnotify/AmazonSNSNotifier.java

    Add the following to the top:

    'import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;'

    Comment-out or remove:
    if (isEmpty(awsAccessKey) || isEmpty(awsSecretKey)) {
        listener.error("AWS credentials not configured; cannot send SNS notification");
        return;
    }

    Change From:
    AmazonSNSClient snsClient = new AmazonSNSClient(new BasicAWSCredentials(awsAccessKey, awsSecretKey));

    Change To:
    AmazonSNSClient snsClient = new AmazonSNSClient(new DefaultAWSCredentialsProviderChain());

    Save, compile and deploy

  5. Please add the ability to send out SNS notifications *only* on build failure.

  6. Hi,

    When chnaging the default template message by curstom message how it is possible to add new-line ?

    I tried '\n' but no success.

    Any idea ?

    Franck

  7. It looks like the plugin does not work when we are behind a corporate proxy. Trying to understand what is the best way to get this plugin working when the jenkins server is behind corporate proxy.

  8. Can you add support for Jenkins DSL?

  9. I got the below error and the notification was not sent to SNS.

    ERROR: Failed to send SNS notification: Unable to execute HTTP request: sns.cn-north-1.amazonaws.com

    from the Jenkins log I didn't find any error log, any idea can help me?

     

    I checked the sns endpoint in Beijing is "sns.cn-north-1.amazonaws.com.cn", maybe this is the root cause, Could author correct this or guide me to correct it?

     

Write a comment…