Overview

Jenkins Deployment Dashboard Plugin for Amazon EC2 Environments

1 Comment

This blog article describes a new Jenkins plugin we developed as a result of the Continuous Delivery in the Cloud blog series. In the initial blog series we explained the setup of a Delivery pipeline based solely on Open Source tools. In order to manage the server environments of an application from a central dashboard, we generated a simple deployment dashboard. Afterwards we received a lot of feedback from readers and customers if the dashboard is a Jenkins plugin and if they could use it. Thats when we started with the development of the Jenkins EC2 Deployment Dashboard Plugin. Now it became stable enough to be officially released.

What problem does the plugin solve?

Typically companies have different environments where they test new versions of an application before they deploy the latest and greatest to production. As a minimum you should have a production, staging and at least one test environment.

Test environments are frequently updated with new versions and afterwards deployed to a staging server for additional acceptance tests. In order to achieve transparency for project teams (i.e. developer, business analysts, product owner, …) a central dashboard is quite useful to have an overview, which version of a software is deployed on which environment. In case a product owner wants to deploy a specific version of the software to staging or production, a simple one-click deployment would be great.

This plugin tries to solve the transparency and one-click deployment problems.

What are the prerequisites for using the Jenkins EC2 Deployment Dashboard plugin?

You need the following tools and environments to be able to use the plugin:

  • Amazon EC2 instances for production/staging/test environments
  • Artifactory or Nexus for storing your software artifacts (i.e. WAR, EAR, RPM, …)
  • Jenkins for building and deploying your software (http://jenkins-ci.org)

Dashboard Views

Here is a screenshot of the Jenkins deployment dashboard. It gives you an overview of all configured EC2 instances. It displays the current state, the deployed artifact version, uptime, instance type and the current IP. It also gets all artifact versions from your artifact repository. Currently the plugin supports jFrog Artifactory and Sonatype Nexus as artifact repositories.

1-dashboard

Basic Workflow

  • A Continuous Integration Job builds the latest version of your software and uploads the artifact to an artifact repository.
  • From the deployment dashboard you select an available version of your software from a dropdown list and select an environment you want to deploy to.
  • A deployment job is triggered with VERSION and ENVIRONMENT as parameters that can be used to download the correct artifact and execute your custom deployment scripts. Afterwards the EC2 environment is automatically tagged with the VERSION.

Jenkins Plugin, Artifact Repository, AmazonEC2 Instances

Plugin Usage

Global Jenkins Configuration

The plugin is now available from the Jenkins Update site. Thats the easiest way to install the plugin. To configure the plugin follow these steps:

The Artifact Repository will be used later on from the dashboard to check for available artifact versions that can be deployed to the configured environments.

0-jenkins-configuration-artifactory

Global Credentials Configuration

Next go to http://localhost:8080/jenkins/credential-store/

  • Manage Credentials to setup your AWS credentials
  • Again Test the connection

The AWS credentials are required to gather EC2 environment information. In case you still have to create your AWS access key, please follow the AWS Credentials section at the bottom of this page.

0-jenkins-configuration-credentials

Deployment Job Configuration

On the Jenkins front page create a new parameterized Job called “Deploy Job” that we will use later for the deployment configuration:

  • Add a Text Parameter named VERSION
  • Add a Text Parameter named ENVIRONMENT
  • Add a Build Step and select EC2 Environment and select your previously configured AWS Credentials

The Build Step will automatically tag the specified EC2 environment with the provided VERSION. You can add your custom deployment scripts in this job and use the provided parameters to download the correct artifact from your artifact repository and deploy it to the environment. Make sure to select the correct AWS credentials and AWS region for the EC2 environments that you want to deploy to.

3-deployJob

Dashboard View Configuration

The last step is to configure the deployment dashboard view.

  • Create a new View and select Deployment Dashboard under http://localhost:8080/jenkins/newView
  • Configure the View
    • Check the checkbox if you want to deploy artifacts using the dashboard view
    • Add groupId and artifactId of the artifact you want to deploy (the plugin will search your artifact repository with the given groupId and artifactId)
    • Add your EC2 server environment you want to monitor and manage (in the dropdown list you should be able to find all available EC2 server)
    • For Build Job add the Job you configured previously for deploying the application called “Deploy Job”
    • Save the configuration

5-view-config

Now you should be able to see the status of your EC2 instances, the versions tags and other details. On top of the dashboard you can select the available versions of the artifact and the environments you want to deploy to. When you click the Deploy App Button the deploy job will be triggered with two parameters:

  • VERSION
  • ENVIRONMENT

It is up to you now to use these parameters and pass them to your custom deployment scripts (i.e. ShellScript, Puppet, Chef, Ansible, …).

AWS Security Section

AWS EC2 instances can be tagged with custom tags. This plugin uses tags to identify the specified environments and stores the deployed software version in that tag. Here is an example screenshot from the AWS Management Console. The EC2 instance with the ID i-294e3b6b has been tagged with the version 1.4.416.

4-aws-tags

Create AWS Access Key

Please follow these steps to configure the necessary AWS Credentials:

  • Open https://console.aws.amazon.com/iam/home?#users
  • Create new IAM User
  • Attach User Policy → Custom Policy → Select → Set Policy Name → Paste Policy statement from below
    • allow User to create tags
    • allow User to delete tags
    • allow User to describe instances

You can use the following Policy Statement to create an access key with the correct permissions:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1412928158000",
      "Effect": "Allow",
      "Action": [
        "ec2:DeleteTags",
        "ec2:DescribeInstances",
        "ec2:CreateTags"
      ],
      "Resource": [
        "*"
      ]
    }
  ]
}

Summary

I hope you will find this plugin useful for your daily work. For suggestions and improvements feel free to leave your comments below or fork the git repository at https://github.com/jenkinsci/ec2-deployment-dashboard/.

 

Kommentare

  • Bruce Edge

    20. February 2015 von Bruce Edge

    Nice work, well integrated, but too restrictive for our needs.
    AFAICT you can’t add new environments.
    How is the deployment executed, and what are the target requirements?
    Does this expect the deplopyable to be web app and the target a web app container ala jetty/tomcat?

Comment

Your email address will not be published. Required fields are marked *