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.
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"codedeploy:Batch*",
"codedeploy:CreateDeployment",
"codedeploy:Get*",
"codedeploy:List*",
"codedeploy:RegisterApplicationRevision"
],
"Effect": "Allow",
"Resource": "*"
},{
"Effect": "Allow",
"Action": [
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::codedeploys3/*"
]
}
]
}
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.
THANKS
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Abhishek Kumar
Abhishek is Redhat and AWS Certified and a keen python enthusiast. His hobbies are cycling and volleyball.