Make sure you already config AWS CodeDeploy for your desired AWS EC2 server. Check this blog if you want to set it up.
- Install Jenkins Plugins:
Amazon Web Services SDK,
AWS CodeDeploy Plugin for Jenkins,
- Generate key, if you don’t have one already:
$ ssh-keygen -o -a 100 -t ed25519
- Add public key into bitbucket
- Add bitbucket webhook to notify Jenkin
- Add private key into Jenkins:
- Go to AWS console and generate a AWS access key:
AWS Access and Secret keys to use for this deployment. At minimum the keys must be allowed to execute
s3:Put*. It’s a best practice to have these keys be from an IAM role with limited scope.
If your Jenkins install is running on an EC2 instance with an associate IAM role, you can leave these fields blank. You will just need to ensure that the role has the correct policies.
- Add AWS access and secret keys to Jenkins:
- In Jenkins configuration, click
Build when a change is pushed to BitBucketand
Add timestamps to the Console Output
Deploy an application to AWS CodeDeploy
- finish and test
Go ahead and testing your whole workflow by pushing some noticeable code changes to bitbucket.