Trigger Jenkins job when a S3 file is updated Trigger Jenkins job when a S3 file is updated jenkins jenkins

Trigger Jenkins job when a S3 file is updated


You can use a combination of SNS Notifications for new artifacts in the S3 bucket https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html and the Jenkins AWS SQS plugin to trigger a build (https://github.com/jenkinsci/aws-sqs-plugin)

A little bit of manual configuration is required in terms of the AWS SQS plugin, but it should work.

S3 Upload > SNS Notification > Publish to SQS > Trigger Jenkins Build

Ideally it would be straight to Jenkins like so: S3 Upload > SNS Notification > Publish to Jenkins HTTP Endpoint > Trigger Jenkins Build

Hope this helps


We can write a icron job if linux or powershell script if windows, which queries a particular s3 bucket for the given string, if it finds then u can trigger the Jenkins job.For doing this, the Jenkins instance must be in the AWS itself if we are trying to add an IAM role, if not we need to add aws credentials.


To implement S3 Upload > Publish to SQS > Trigger Jenkins Build (assuming you have appropriate AWS Users, Roles and Policies attached):

Create an AWS SQS Queue

After creating an AWS SQS Queue, on AWS S3 bucket we need to configure:

  1. S3 Bucket "Events" section to register an "Object Create" event

  2. Provide the SQS Queue name. Detailed documentation.

On Jenkins, we need to:

  1. Install Plugin AWS SQS from the Jenkins Install Plugin Page

  2. Configure AWS SQS Plugin to point to SQS queue in Jenkins System Configuration

  3. Configure the Jenkins Job to "Trigger build when a message is published to an Amazon SQS queue"

  4. Note that Jenkins user MUST have Read access to SQS(all Read fucntions) in addition to S3 access.

Now whenever someone adds/updates anything on the bucket S3 sends an event notification the SQS which is then polled by the Jenkins AWS SQS plugin and the respective Job Build is triggered!

This article explains the process in detail AWS to Github to Jenkins. If you are just using S3 then you would skip the Github part.