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.
Our Jenkins Wiki Page is located here: https://wiki.jenkins.io/display/JENKINS/AWS+CodeCommit+Trigger+Plugin
Use JIRA to report issues / feature requests
Use the tf-codecommit-sqs module to create your CodeCommit repos created with provided linkage with SQS/SNS.
General steps to config your Amazon Services:
-
Create a CodeCommit Repo
-
Open the Repo, create Triggers that will connect to a webhook through Amazon Simple Notification Service (SNS)
-
Create SNS Topic subscribe to a Simple Queue Service (SQS) queue
-
Open the SQS queue, do queue actions to subscribe it to SNS Topic
-
Make sure the AWS Credentials used for this Plugin has Permission to
-
sqs:ReceiveMessage
-
sqs:DeleteMessage
-
sqs:DeleteMessageBatch
-
sqs:GetQueueAttributes
-
sqs:ListQueues
(optional)
-
-
Go to
Jenkins > Manage Jenkins > Configure System
on your Jenkins -
Go to
AWS Code Commit Trigger SQS Plugin
-
Configure a queue
-
Select the name of the queue you just created (the list auto-loaded using selected AWS Credentials)
-
Select "Aws Credentials" from the list or click on button "Add Credentials" to create one
-
Access Key ID
andSecret Access Key
is setup using AWS Credentials -
NOT support for
IAM Roles and IAM MFA Token
-
-
Click on Test access
You should see a success message.
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.
-
Go to
Jenkins > $job
-
Click on
Configure
-
Scroll down to
Build Triggers
-
Check
Build when a message is published to an SQS queue
-
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.
Sample Pipeline Script
node { stage('Preparation') { sh "echo 'Preparation phase'" checkout scm: [ $class : 'GitSCM', userRemoteConfigs: [[url: "https://git-codecommit.us-west-2.amazonaws.com/v1/repos/testjenkins", credentialsId: "test"]], //mins branches : [[name: "refs/heads/master"]], ], poll: false } stage('Build') { sh "echo 'Build phase'" } stage('Results') { sh "echo 'Result phase'" } }
Configuration sample
-
Fork it
-
Create your feature branch (
git checkout -b my-new-feature
) -
Write your code and tests
-
Ensure all tests still pass (
mvn clean verify -Pit
) -
Commit your changes (
git commit -am 'Add some feature'
) -
Push to the branch (
git push origin my-new-feature
) -
Create new pull request
AWS CodeCommit Trigger Plugin is provided by Ribose Inc. (GitHub page: Ribose Inc.)
Full text: Apache License