Skip to content

phuonghuynh/aws-codecommit-trigger-plugin

 
 

Repository files navigation

AWS CodeCommit Trigger Plugin

aws codecommit trigger plugin :license apache blue

Introduction

A Jenkins plugin that triggers jobs on repo update events by AWS CodeCommit, through the AWS Simple Queue Service (SQS) and Simple Notification Service (SNS).

The advantage over the original AWS SQS Plugin that this plugin allows subscribing to multiple branches using the same SQS queue, meaning that:

  • you no longer need to create a SQS queue per CodeCommit repo

  • an update to the dev branch will no longer trigger all jobs that subscribe to that CodeCommit repo.

The original AWS SQS Plugin was written (and still maintained) by Markus Pfeiffer of M-Way Solutions GmbH.

Use JIRA to report issues / feature requests

Quick Setup With Terraform

Use the tf-codecommit-sqs module to create your CodeCommit repos created with provided linkage with SQS/SNS.

Manual Setup

General steps to config your Amazon Services:

  1. Create a CodeCommit Repo

  2. Open the Repo, create Triggers that will connect to a webhook through Amazon Simple Notification Service (SNS)

  3. Create SNS Topic subscribe to a Simple Queue Service (SQS) queue

  4. Open the SQS queue, do queue actions to subscribe it to SNS Topic

  5. Make sure the AWS Credentials used for this Plugin has Permission to READ(sqs:ReceiveMessage) & DELETE(sqs:DeleteMessage) message from the SQS Queue.

Jenkins System Configuration

  1. Go to Jenkins > Manage Jenkins > Configure System on your Jenkins

  2. Go to AWS Code Commit Trigger SQS Plugin

  3. Configure a queue

    • Select the name of the queue you just created (the list auto-loaded using Access key ID & Secret key)

    • Select "Standard Aws Credentials" from the list or click on button "Add Credentials" to create one

  4. Click on Test access

You should see a success message as in the screenshot below. If you get an error message make sure you entered the credentials correctly. If you still see errors double check the user, group and permissions you set up on Amazon Web Services.

Jenkins configuration test

If you get the error Unable to find a region via the region provider chain, create the directory .aws inside the Jenkins home directory. Then inside the .aws directory add the config file with the following configuration.

[default]
output = json
region = <region where is your repository>
Region not found error

Jenkins Job Configuration

  1. Go to Jenkins > $job

  2. Click on Configure

  3. Scroll down to Build Triggers

  4. Check Build when a message is published to an SQS queue

  5. Select the queue you created previously

For cost savings, the plugin does not start monitoring a queue until at least one job has been configured to listen to messages from a queue.

You can use the same queue for multiple jobs or you can create a new queue for each job. Keep in mind that monitoring multiple queues will increase the amount of requests your Jenkins will have to send to AWS.

Normally you would use the same queue and topic for multiple jobs, but for billing purposes it may be easier to use multiple queues, especially if you’re running builds on behalf of a customer.

Test your setup

If you’ve set up everything correctly pushing a change to the Git repository on CodeCommit should now trigger a build on Jenkins. If nothing happens, make sure the job has been set to use messages posted to SQS as a build trigger.

Build trigger configuration

Contributing

  1. Fork it

  2. Create your feature branch (git checkout -b my-new-feature)

  3. Write your code and tests

  4. Ensure all tests still pass (mvn clean verify -Pit)

  5. Commit your changes (git commit -am 'Add some feature')

  6. Push to the branch (git push origin my-new-feature)

  7. Create new pull request

Authors

AWS CodeCommit Trigger Plugin is provided by Ribose Inc. (GitHub page: Ribose Inc.)

License

Full text: Apache License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 97.4%
  • HTML 1.6%
  • Other 1.0%