Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
CI
LIGHT
T H O M A S K O C H - @ T O M Y _ K O C H
P Y U N C O N F H A M B U R G – S E P T E M B E R 2 0 1 5
WTF
• Light indicator for
Jenkins CI-Server
• Shows current state of
automated tests/builds
• Uses Raspberry Pi + Python
+...
RELATED WORK
• Build-Ampel
– Arduino, RSS-Feed (USB-device – 99 EUR)
– http://www.agile-hardware.de/tag/ampel/
• Using a R...
RELATED WORK
• Raspberry Pi Internet Monitor
– „do we have internet connection“?
– uses optoelectronic coupler to separate...
INGREDIENTS
• Raspberry Pi (model B 512MB RAM) http://www.raspberrypi.org
• SD Card 8GB for Raspian https://www.raspbian.o...
RASPBERRY PI
GPIO
SOFTWARE
<100 LOC
• CI-checker.py
– Polling of Jenkins-Servers via Jenkins-API
– Uses Python API client http://python-jenk...
SOFTWARE
CONTROLLER.PY
from cichecker import CIChecker
from light import Light
import time
class LightController(object):
...
FINALLY
• From prototype to
„product“ state
– Start with breakout
board
– Finally switch to plate
– Do some soldering
– Pr...
BUILDING BLOCKS
IN
ACTION
kitchen/network corner
@orbiteam
Full (German) Slides:
http://de.slideshare.net/tomykoch
Upcoming SlideShare
Loading in …5
×

CI Signal Light in less than 100 Line of Python Code

955 views

Published on

English Lightning Talk given at PyUnconf in Hamburg in 09/2015
how to build a Jenkins CI signal light device using python and Raspberry Pi

Published in: Software
  • Be the first to comment

CI Signal Light in less than 100 Line of Python Code

  1. 1. CI LIGHT T H O M A S K O C H - @ T O M Y _ K O C H P Y U N C O N F H A M B U R G – S E P T E M B E R 2 0 1 5
  2. 2. WTF • Light indicator for Jenkins CI-Server • Shows current state of automated tests/builds • Uses Raspberry Pi + Python + some hardware hacks
  3. 3. RELATED WORK • Build-Ampel – Arduino, RSS-Feed (USB-device – 99 EUR) – http://www.agile-hardware.de/tag/ampel/ • Using a Raspberry PI to control an extreme feedback device – Uses Cleware USB traffic light • http://www.cleware-shop.de/ (ca. 50 EUR) – Shell-script using curl and awk • And proprietary Clewarecontrol https://blog.codecentric.de/en/2013/07/using-a-raspberry-pi-to-control-an-extreme-feedback-devices/
  4. 4. RELATED WORK • Raspberry Pi Internet Monitor – „do we have internet connection“? – uses optoelectronic coupler to separate 5V/24V circuits – http://www.instructables.com/id/Raspberry-Pi-Internet-Monitor
  5. 5. INGREDIENTS • Raspberry Pi (model B 512MB RAM) http://www.raspberrypi.org • SD Card 8GB for Raspian https://www.raspbian.org • Power supply for Raspi (5v Micro USB), USB keyboard • Red/green LED Industrial Tower Signal (24v) - www.ebay.de • Power supply for light (24v) • Network cable (or Wireless 802.11b/g/n USB adaptor) • 2 resistors 180 Ohm • 1 optoelectronic coupler LTV847 • breakout board / prototyping plate • ca. 100 EUR in total
  6. 6. RASPBERRY PI GPIO
  7. 7. SOFTWARE <100 LOC • CI-checker.py – Polling of Jenkins-Servers via Jenkins-API – Uses Python API client http://python-jenkins.readthedocs.org $ pip install python-jenkins • Light.py • Handle control of light device via GPIO Pins and optoelectronic coupler circuit • Uses GPIO Python Wrapper RPi.GPIO https://pypi.python.org/pypi/RPi.GPIO • Controller.py • Integrates checker and light modules • Simple check-control-sleep cycle
  8. 8. SOFTWARE CONTROLLER.PY from cichecker import CIChecker from light import Light import time class LightController(object): def __init__(self, delay=60, verbose=False): self.checker = CIChecker(verbose=verbose) self.light = Light(verbose=verbose) self.delay = delay def wakeup(self): if self.checker.check(): self.light.green() else: self.light.red() def sleep(self): time.sleep(self.delay) def loop(self): while True: self.wakeup() self.sleep() if __name__ == "__main__": controller = LightController(verbose=True) controller.loop()
  9. 9. FINALLY • From prototype to „product“ state – Start with breakout board – Finally switch to plate – Do some soldering – Prepare for 24/7 operations ,-)
  10. 10. BUILDING BLOCKS
  11. 11. IN ACTION kitchen/network corner @orbiteam Full (German) Slides: http://de.slideshare.net/tomykoch

×