Raspberry Pi Jenkins Light on NodeJs
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
configs
dev
modules
tests
.eslintrc
.gitignore
.travis.yml
LICENSE
README.md
package.json
run.js

README.md

Raspberry Pi Jenkins Light

build npm js-standard-style GitHub license status

Demo

Note: this package was tested on Raspberry Pi 2.

Read article about this project.

Installation

  • SSH to Raspberry Pi
  • $ sudo su (need for install Node.js)
  • Install NodeJs 5.x
    • Add repository $ curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
    • Run $ apt-get install nodejs
  • From GitHub sources:
    • Clone repository: $ git clone https://github.com/antonfisher/rpi-jenkins-light.git
    • $ cd rpi-jenkins-light
    • Install dependencies: $ npm install
  • From NPM:
    • $ npm install rpi-jenkins-light.

Configure

Edit $ vim configs/config.js file:

module.exports = {
    rpi: {                          // Raspberry Pi sub-config
        gpio: {                     // GPIO [General Purpose Input Output] config
            color: {
                red: 15,            // pin # for red color
                yellow: 11,         // pin # for yellow color
                green: 7            // pin # for green color
            },
            outputLevel: {
                on: true,  // 3v3   // led turn on output level
                off: false // 0v    // led turn off output level
            }
        }
    },
    jenkins: {                      // Jenkins sub-config
        interval: 5 * 1000,         // requests interval
        host: '10.0.0.1',
        port: '8080',
        view: 'JenkinsLight',       // http://localhost:8080/view/%VIEW_NAME%/
        demoMode: true              // demo turn on red-yellow-green lights
    }
};

Demo mode

To run light in demo mode set property: demoMode: true in jenkins section in configs/config.js.

Connect LEDs to Raspberry Pi

Example config works with this configuration: LEDs connections

Pins map

Pins

More about Pi's pins...

Final version

Under hood 1

Under hood 2

Configure Jenkins

  • Open Jenkins main page
  • Create new list view called JenkinsLight
  • Add monitored tasks to this view.

The colors indicate (by priority):

  • Blinks yellow -- at least one build is running
  • Red -- at least one build is failed
  • Green -- all builds are OK.

Jenkins View

Run

  • $ sudo su (need for GPIO module)
  • From GitHub sources:
    • $ node run.js
  • From NPM:
    • $ node ./node_modules/rpi-jenkins-light/run.js.

Autorun application after reboot

sudo su #need for global modules
npm install pm2 -g
pm2 startup
pm2 start run.js -o "/dev/null" -e "/dev/null" #run w/o logging
# pm2 start run.js #run w/ logging
pm2 save

Advanced

Disable ext4 journal:

sudo -i
echo u > /proc/sysrq-trigger 
echo s > /proc/sysrq-trigger 
tune2fs -O ^has_journal /dev/mmcblk0p2
e2fsck -fy /dev/mmcblk0p2
echo s > /proc/sysrq-trigger 
echo b > /proc/sysrq-trigger

Tests

  • Use NodeJs v5.x
  • $ npm install --dev
  • $ npm test.

Release History

  • 1.1.0 Tests and improvements
    • configuration examples
    • test with jenkins mock
  • 1.0.0 Initial release.

ToDo

  • add link to article
  • npm global module

License

Copyright (c) 2015 Anton Fisher a.fschr@gmail.com

MIT License. Free use and change.