Integrate CodeDeploy with Jenkins
Posted By : Abhishek Kumar | 31-Mar-2017
We can integrate the jenkins with AWS Codedeploy to deploy the build on AWS autoscaling group or Intances collection (which are configured in AWS codedeploy)
Assuming that we have Jenkins setup and running, we need to install CodeDeploy plugin in Jenkins.
Login to AWS webconsole and go to AWS IAM, Create a User "CodeDeployUser". Also create a S3 bucket for Codedeploy "codedeploys3"
Create a IAM policy "CodeDeployPolicy" with permissions to codedeploy deployments rights and S3 put rights.
Now attach this policy to "CodeDeployUser" and Create a Access Key and Security Key. Save this credentials as we will need
To install Codedeploy plugin. Go to Jenkins -> Manage Jenkins -> Mange Plugins -> Search for AWS CodeDeploy Plugin for Jenkins
Now to go Project "JenkinsCodedeployTest" -> Configure .
Configure your Project as per requirement. Now include the appspec.yml file in your source code root location
Now go to PostBuild Action. Select "Deploy an application to codedeploy"
Then fill following configuration
AWS CodeDeploy Application Name: Enter Codedeploy application name
AWS CodeDeploy Deployment Group: Enter Deployment Group name
AWS CodeDeploy Deployment Config: Enter the Deployment Configuration like "CodeDeployDefault.OneAtATime"
AWS Region: "Region in which S3 bucket is present"
S3 Bucket: "Bucket Name which we created to store Codedeploy file"
Select Deploy Revision
Use Access/Secret Key: Enter your access key and secret key
These are the basice configuration need to use codedeploy. You can configure more as per requirements.
Now save the configuration
Now Deploy the Build.
During the build the Jenkins will Build your application as you have specified and after the build is complete it will compress your Build and Upload it S3 bucket. Then it will Start the deployment using S3 object which jenkins uploaded.
Abhishek is Redhat and AWS Certified and a keen python enthusiast. His hobbies are cycling and volleyball.