![]() IMAGE=$(echo %message% | jq -r '.Records.s3.object.key') The custom script is: # Extract bucket name and image name from the JSON messageīUCKET=$(echo %message% | jq -r '.Records.s3.bucket.name') Build step #1: Get the information from the message In this demo, we will use the Command line runner for our build steps. Now we are ready to set up our build steps! On the Build features page using the “AWS Credentials” build feature, TeamCity will now securely provide credentials for the build steps. Next, we want to check our build steps will work with AWS. On the project level, add a new connection for AWS using the same IAM user credentials we created before.Ĭheck the connection using the Test Connection button: Now it’s time to grant the scripts permission to download images from the S3 bucket. That’s it! You can check the trigger in TeamCity to see if it was updated correspondingly in the Subscription Info section: AWS Connection Now go to the AWS console, the SNS service, and subscribe to TeamCity by using the provided endpoint URL. On the Build Customization tab, ask TeamCity to use the message parameter to publish an SNS message. Specify its name, and don’t forget to copy the endpoint URL. On the Triggers page, add a new Amazon SNS Trigger. The trigger will update the value for every running build as every new message appears. Let’s create the parameter that we will use – the value can be anything. When a SNS message will trigger our process, TeamCity puts the message into a parameter used in later steps. Grant TeamCity permission to get files from the bucket.Extract image properties like its name and the storge bucket from the SNS Trigger.Before we start working on our steps, we need to do a couple of things: Now we have an empty build configuration. In General Settings, specify the Artifact path. TeamCity will ask us about a VCS root we want to use, but since we don’t need one, we can skip this. Now it’s time to create a build configuration with the trigger that will run our processing tasks. How to create an SNS topic and S3 bucket is out of the scope of this article, but you can find step-by-step instructions in the official documentation. Grant the build configuration permission to interact with AWS.įirstly, we need to create resources on the AWS side.Set up an AWS Connection using the IAM user’s key.Create an IAM user for TeamCity and attach the ‘ AmazonS3FullAccess’ IAM policy.Set the bucket to push notifications to the topic. ![]() Create an AWS SNS Topic with a name, e.g., ‘new-image-into-the-demo-storage’. ![]()
0 Comments
Leave a Reply. |