When I walked into the office this morning I couldn't help but notice the red glow coming from our team room. First thought: "Who jacked up the code?" I looked at our Slack channel and saw that integration tests had failed. Using the link in Slack, I was taken directly to the entry in the Jenkins logs, which showed that it was none other than Yours Truly who jacked up the code! I had failed to update the shared data access layer when I committed my code last night. With egg on my face, I corrected the issue. By the time the team arrived in the office, they were greeted with that calm blue glow we've all come to enjoy.
While Continuous Integration (CI) can be fast and effective, if environmental health is not confirmed prior to integration you may still end up in “Integration Hell”. With multiple developers checking in code throughout the day, a line of bad code from one could cause issues for another. Continuous Integration, is in part, the practice of integrating new code in to the mainline early and often to avoid “Integration Hell”.
Automation is a key feature of a successful CI practice. With multiple contributors checking in code several times a day, it is impractical to perform builds and tests manually. Instead, automated integration and testing of code is performed using a suite of tools: version control (Git), CI (Jenkins), build automation (Maven) and artifact repository (Nexus). Once code is locally-tested and committed, these tools build and test the environment with no further intervention.
There is a catch here...what if the environment you are checking your code into is currently unhealthy? Before you check-in your code, you need to check Jenkins and sift through the logs to ensure that the last user's code did not screw anything up. With Jenkins + Slack, you can just look at the Slack channel!
Yep, Integration is Awesome!
“Slack is most useful when you can see everything your team is doing — that includes all the tools you use outside of Slack! Integrations let you automatically pull information and activity from outside tools into Slack in a way that's timely, relevant, and searchable. “ – Slack Integrations
Slack with Jenkins allows for messages to be broadcast on your Slack channel, giving you confirmation of the health of your environment with a simple glance - no digging through log events. It is simple and effective. Slack Integrations takes you through six simple steps to get your designated Slack channel up and integrated with Jenkins alerts.
Add Some Pi
For the slightly more ambitious, the same result – simple confirmation of the health of the environment – can be achieved without having to log into any systems. For less than the cost of a round of beers for your development team, we setup a Raspberry Pi with a daemon that calls the Jenkins API and parses the returned XML for the status of jobs we are interested in. The Pi calls on an open-source Python library, and based on the status returned from the Jenkins API call, the appropriate color lights are lit on an LED strip driven by the Pi.
Successful completion of Unit and Integration tests means the environment is healthy – blue lights (Jenkins default)
If Unit or Integration tests should fail, the environment is unhealthy – red lights
Now, prior to checking in new code, we glance up, see the light and know the state of the environment and react appropriately to the current state.
When I walk in the office tomorrow, I will do so with the anticipation of seeing that calm blue glow coming from our team room. Blue lights go great with a fresh cup of coffee and a warm bagel smeared with a dollop of cream cheese. If instead, I find myself immersed in red light, I know I can quickly identify and correct the problem before the rest of the team shows up and scarfs down the last of the bagels.