Jenkins + Bitbucket + AWS EC2 + CodeDeploy


Make sure you already config AWS CodeDeploy for your desired AWS EC2 server. Check this blog if you want to set it up.


  1. Install Jenkins Plugins: Amazon Web Services SDK , AWS CodeDeploy Plugin for Jenkins , Bitbucket Plugin
  2. Generate key, if you don’t have one already:

$ ssh-keygen -o -a 100 -t ed25519

  1. Add public key into bitbucket Access Keys list:

  1. Add bitbucket webhook to notify Jenkin

  1. Add private key into Jenkins:

  1. 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 codedeploy:* and 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.

  1. Add AWS access and secret keys to Jenkins:

  1. In Jenkins configuration, click Build when a change is pushed to BitBucket and Add timestamps to the Console Output

  2. Add Post-build Action -> Deploy an application to AWS CodeDeploy

  1. finish and test
    Go ahead and testing your whole workflow by pushing some noticeable code changes to bitbucket.



Jenkins with BitBucket




1 comment

Leave a Reply