So I have an Alexa echo dot at home. Use it to control stuff but I wanted it to do more like release and deploy the stuff I build.
This is how you can integrate Alexa voice service with Jenkins.
For receiving commands from Alexa and sending them to Jenkins we need a server and some code. First start with the server i use docker and a docker-compose to set it up.
Dockerfile
FROM ubuntu MAINTAINER "Mattias Hemmingsson" <matte.hemmingsson@gmail.com> RUN apt-get update && apt-get install python-pip -y RUN apt-get update && sudo apt-get install build-essential autoconf libtool pkg-config python-opengl python-imaging python-pyrex python-pyside.qtopengl idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev -y RUN apt-get update && apt-get install libpq-dev python-dev libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev libffi-dev -y RUN pip install flask-ask python-jenkins WORKDIR /code CMD python app.py
docker-compose.yml
jenkins: build: . ports: - 5000:5000 volumes: - .:/code
then some code in the app.py
from flask import Flask, render_template from flask_ask import Ask, statement import jenkins app = Flask(__name__) ask = Ask(app, '/') @ask.intent('JenkinsIntent') def hello(app): server = jenkins.Jenkins('http://jenkins:8080', username='admin', password='admin') if str(app) == "rentalfront": back = server.build_job('rentalfront') print back print "deploy rentalfront" if str(app) == "farepaymnet": print "Deploy farepaymnet" return statement("Deploying {0}".format(app)) if __name__ == '__main__': app.run(host='0.0.0.0',debug=True)
And you will change the setitng so it matches you jenkins and alos change so correct word like rentalfront matches what you want to build.
We are going to say “alexa tell jenkins to build rentalfront” and then we ere matches rentalfront aginst the app you want to build.
start it up with
docker-compose build docker-compose up
Now we need alexa to connect to you local laptop and connect go to https://ngrok.com/ and download and start it against port 5000
./ngrok http 5000
You will see a https link remember it https://9242f0e6.ngrok.io
Time for setting up Alexa go to https://develtoper.amazon.com
Setup a new skill and give it name jenkins (This is the calling name “alexa tell jenkins” ) and the in the interactions model add the following
{ "intents": [ { "intent": "JenkinsIntent", "slots":[{ "name": "app", "type": "Names" } ] } ]
where names are a custom slot type with the values rentalfront ADD YOUR APPS HERE THAT YOU WANT TO CALL
JenkinsIntent deploy {app}
Go to configuration and att the https link from ngrok
And go to SSL and choose Wildcard cert
And now you should be ready to start using it. go to the test and test write deploy rentalfront to see the json going from Alexa to you app and when it works it time to test from you echo.