nickgrealy / aws-sqs

Jenkins plugin that triggers builds on events that are published via Amazon Simple Queue Service (SQS) (Allow default IAM access (no access/security keys required).
Apache License 2.0
0 stars 41 forks source link

Multiple CodeCommit repos using the same SQS queue #2

Open ronaldtse opened 8 years ago

ronaldtse commented 8 years ago

Hi Nick,

Thank you for the great work with the aws-sqs plugin!

We are trying to use multiple CodeCommit repos with a single SQS queue. Currently, when the plugin receives any sort of notification from CodeCommit, it triggers the build of ALL jobs that matches the branch (of the SNS message), but without consideration of the repo that generated it (eventSourceARN).

For example, if I have two repos ("FOO" and "BAR") and a job for each that tracks the "master" branch, a notification of "FOO/master" being updated will trigger both jobs, which is obviously not correct.

Is it possible to extend this plugin to use the eventSourceARN to filter out which repo to trigger? Without this we will have to create N SQS queues for N repos, which can be a lot, and also makes the Jenkins configuration of them very cumbersome.

For your reference here is a sample SNS message that shows where eventSourceARN is located.

{
  "Records": [
    {
      "awsRegion": "us-east-1",
      "codecommit": {
        "references": [
          {
            "commit": "eedd7213b474f914db1c25c3313d9e7be6ba71d0",
            "ref": "refs/heads/feature/my_new_feature"
          },
          {
            "commit": "eedd7213b474f914db1c25c3313d9e7be6ba71d0",
            "ref": "refs/tags/v110"
          }
        ]
      },
      "customData": "",
      "eventId": "464817b2-e391-4cf9-bf52-bd0ed1ad6900",
      "eventName": "TriggerEventTest",
      "eventPartNumber": 1,
      "eventSource": "aws:codecommit",
      "eventSourceARN": "arn:aws:codecommit:us-east-1:{aws-account-id}:{codecommit-repo-name}",
      "eventTime": "2016-10-11T13:52:59.745+0000",
      "eventTotalParts": 1,
      "eventTriggerConfigId": "464817b2-e391-4cf9-bf52-bd0ed1ad6900",
      "eventTriggerName": "notifications",
      "eventVersion": "1.0",
      "userIdentityARN": "{aws-user-arn}"
    }
  ]
}

Thank you for your help!

phuonghuynh commented 7 years ago

@ronaldtse @nickgrealy likewise issue https://github.com/riboseinc/aws-sqs-plugin/issues/2

PR for it submitted to our fork and is testing https://github.com/riboseinc/aws-sqs-plugin/pull/1