Jenkins + Alexa: Say Hello to Voice Controlled CI/CD

This is a guest post by Kesha Williams.

Integrating Jenkins with Alexa to launch your pipelines and obtain results
about your deployments through voice is easier than you think. Learn how Alexa
Champion, Kesha Williams’, latest side project teaches Alexa to deploy code to
the cloud.

Jenkins with Amazon Alexa

Alexa (named after the ancient library of Alexandria) is Amazon’s Artificial
Intelligence (AI) powered intelligent voice assistant that runs in the cloud.
Software engineers make Alexa smarter by creating apps, called skills. From
the time that I developed my first Alexa skill, I dreamed of deploying my Java
projects to the cloud via voice. For me, telling Alexa to deploy my code is
the ultimate level of cool! I recently made my dream a reality when I devoted
a weekend to developing my newest Alexa skill, DevOps Pal. In this blog, I
will show you how I developed DevOps Pal and hopefully inspire you to build
your own version.

Why Choose Voice to Deploy Code

Voice-first technology is revolutionizing how we interact with technology because the interaction is simple, frictionless, and time-saving.
For me, voice is an easier way to control Jenkins and retrieve results about my deployments without having to touch a keyboard.
In this use case, voice is another access point for data and is a way to further automate the process of building, testing, and deploying a Java project to the cloud, improving efficiency.

Continuous Integration and Continuous Delivery (CI/CD)

If you’re working with DevOps, you understand the need for Continuous Integration and Continuous Delivery (CI/CD) to automate the software delivery pipeline in a reproducible way.
CI/CD is the practice of continuously building, testing, and deploying code once it’s committed to version control.
DevOps and CI/CD provides software engineering teams with confidence in the code being pushed to production and shorter development lifecycles, which in the end produces happier users, clients, and customers.

DevOps Pal Overview

DevOps Pal is a private Alexa for Business skill that is used to kick off a Jenkins pipeline job.
Alexa for Business was the perfect way for me to distribute DevOps Pal since I have the ability to enable the skill on an organization-by-organization basis, which gives me complete control over who has access.
Once DevOps Pal invokes the job, the pipeline status displays in real-time via the Blue Ocean Pipeline Run Details View Page.

DevOps Pal Architecture

I used several components and tools to create DevOps Pal. Let’s review the architecture in detail.

DevOps Pal Skill Architecture

The flow begins by saying, “Alexa, open DevOps Pal and deploy my code”, to the Echo device.

The Echo device listens for the wake word (e.g. Alexa, Echo, Computer, or Amazon), which employs deep learning technology running on the device to recognize the wake word the user has chosen.
Once the wake word is detected, what I say is recorded and sent to the Alexa Voice Service (AVS), which uses speech to text and natural language understanding (NLU) to identify my intent.
My intent is sent to DevOps Pal; the skill acts accordingly by kicking off the Jenkins job and sending a response back using text-to-speech synthesis (TTS), which makes the response natural sounding.

Let’s explore each component in more detail:

  • Alexa Voice Service (AVS) – I often refer to the Alexa Voice Service as the “Alexa brain that runs in the cloud”. The AVS is a suite of services built around a voice-controlled AI assistant. The AVS is flexible enough to allow third parties to add intelligent voice control to any connected product that has a microphone and speaker, so Alexa is not limited to just Echo devices.
  • Alexa Skills Kit (ASK) – ASK is the “SDK” (Software Development Kit) that allows developers to build custom skills for Alexa.
  • Alexa Developer Portal – An Alexa skill includes a voice user interface, or VUI, to understand user intents, and a back-end cloud service to process intents by telling Alexa how to respond. The VUI and the integration with the back-end service is setup and configured through the Alexa Developer Portal.
  • AWS Lambda – A chunk of code that runs in the cloud. Developers can run their code without having to provision or manage servers. Applications created with AWS Lambda are considered to be serverless. Lambda supports several popular languages like Python, Java, Node.js, Go, C#, etc.
  • GitHub – A version control system for the Java project source code.
  • Jenkins on EC2 – I use Jenkins to build, test, and deploy my Java Application Programming Interface (API). Elastic Cloud Computer (EC2) is the virtual server where Jenkins is installed. Jenkins works alongside several other tools:
    1. Maven – A build automation tool for Java projects.
    2. Junit – A testing framework for Java projects.
    3. AWS Command Line Interface (CLI) – This is a command line tool that allows developers to access their Amazon Web Services (AWS) account.
    4. Blue Ocean – This is a plugin for Jenkins that provides an easy to use interface to create and monitor Jenkins pipelines.
  • AWS Elastic Beanstalk – This is an orchestration service that allows developers to deploy and manage web applications in the AWS cloud.
  • Postman – This is an HTTP client for testing APIs and web services.

Voice Interaction Model

The Voice User Interface (VUI) describes the overall conversational flow and is setup via the Alexa Developer Console.

Invocation Name Setup Via Alexa Developer Console

A few important components of the VUI are the Invocation Name (how users launch your skill) and the Intents (phrases a user says to “talk to” or interact with your skill).

Utterances for DeployCodeIntent Via Alexa Developer Console

Specifically, the “DeployCodeIntent” is invoked when a user says one of several phrases (e.g. run jenkins pipeline, run jenkins job, deploy the code, deploy code, or deploy ) or a variation of the phrase like, “deploy my code”.

Backend Fulfillment Logic - Endpoint Via Alexa Developer Console

The endpoint is the destination where the skill requests are sent for fulfillment.
In this case, the backend logic is an AWS Lambda authored in Python.
The business logic in the Python Lambda uses the Jenkins remote access API to trigger the job remotely.
The format of the URL to trigger the job is jenkins_url/job/job_name/build.
The API call uses BASIC authentication and a Jenkins Crumb passed in the HTTP request header for CSRF protection.
Alternatively, since Jenkins 2.96, you can use an API token instead of a Jenkins Crumb and password to authenticate your API call.

Jenkins Job

Jenkins Classic UI

The Jenkins job, ‘alexa-cicd’, is the job invoked from DevOps Pal.
Although, the Jenkins Classic User Interface (UI) is functional, I prefer the Blue Ocean interface because it rethinks the user experience of Jenkins by making it visually intuitive.
Blue Ocean is easily enabled via a plugin and leaves the option to continue using the Jenkins Classic UI should you so choose.

Jenkins Blue Ocean Pipeline Run Details View Page

After Alexa kicks off the ‘alexa-cicd’ job, I navigate to the Pipeline Run Details View Page, which allows me to watch the job status in realtime.
This job has four stages: Initialize, Build, Test, and Deploy.
The final stage, Deploy, uses the AWS Command Line Interface (CLI) on the Jenkins server to copy the artifact to Amazon Simple Storage Service (S3) and create a new Elastic Beanstalk application version based on the artifact located on S3.

Cool Features to Add

The ability to deploy code with voice is just the beginning.
There are several cool features that can easily be added:

  • DevOps Pal can be updated to prompt the user for the specific Jenkins pipeline job name. This adds a level of flexibility that will really empower DevOps teams.
  • Alexa Notifications can be integrated with DevOps Pal to send a notification to the Echo device when the Jenkins job is finished or when it fails. If the job fails, more information about where the job failed and exactly why will be provided. This will prove useful for long running jobs or for getting timely updates regarding the job status.
  • DevOps Pal can be updated to answer direct questions about the real-time status of a specific job.

Want to Learn More

I hope you’ve enjoyed learning more about the architecture of DevOps Pal and deploying code to the cloud using Jenkins and voice.
For more detailed steps, I’ve collaborated with Cloud Academy to author a course, AWS Alexa for CI/CD on the subject.

Originally posted on Jenkins Blog
Author: keshawilliams

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *