Categories
AWS CodeDeploy Continuous Delivery Jenkins

Jenkins Plugin – AWS CodeDeploy

Our company uses Jenkins for our continuous integration. It is responsible for building .NET projects, and sometimes deploying our projects. One of the problems we are trying to solve is being able to deploy Windows services. Currently, we manually deploy these services. We copy and paste files to the right server and then run a batch file to install the service. This process is time consuming and error-prone. We decided to improve these manual deployments with a Jenkins plugin called AWS Codedeploy.

First thing that we need to do is install the Jenkins plugin. Go to your Jenkins site, and install CodeDeploy plugin and restart Jenkins.

Now that we have the plugin up and running, let’s update a job and add our code deploy settings. The plugin needs to know: application name, group name, region, revision info (s3 bucket and prefix), and other settings. Once we have our job setup with codedeploy settings, we can start modifying our applications to instruct aws codedeploy what to deploy and how to do deploy it. We need to add a yml file which contains what files need to be deploy. The file needs to be named appspec.yml and it needs to be in the root of project. Take a look at this page to see appspec examples.

In addition to the appspec file, we also need to install the aws codedeploy agent in our on-premise servers or aws instances. In our case, we will install the agent in our on-premise servers. After installing the agent, we need to register the servers with AWS CodeDeploy. In a nutshell, the agent is listening for request for applications to be deployed.

We now have our application and server ready and it is time to deploy our windows services. After Jenkins builds our .NET window service, the codedeploy plugin will register a new revision and start the deployment process. With the help of appspec hooks, we can use powershell to install and start the service. CodeDeploy provides hooks so that developers can integrate with the different events. We can use BeforeInstall, AfterInstall, ApplicationStart, and ValidateService hooks. For our example, we can use the AfterInstall hook to install the service and then start the service.

Now that we have fully automated our .NET deployments, our developers can spend more time adding new features.