Dynamic Bash Prompt

I have a problem. I keep constantly committing (and pushing) to wrong branches and then keep searching for how to move those commits to the right place. So I decided that bash prompt should remind me, what branch I am currently on. I need a scm tool name (because I use several) and a branch.

Jenkins2 Version 1.0.0 Released

Yesterday I have released version 1.0.0 of my jenkins2 gem. It’s a API client and a command line application at the same time, that allows you to manage your Jenkins. And to be honest I am proud of the code I have pushed. Here is why:

Integration Tests for Test Kitchen Driver

Imagine you write a driver for Test Kitchen. It’s reasonable, if you want to check, if your driver is working before publishing it. But which approach to take? Building the gem and installing it locally, then manually trying to launch Test Kitchen with your driver, does not really feel the way to do it.

Jenkins Build History

Having big Jenkins cluster requires monitoring many things. Lately we started saving information about what build ran on which machine and when. Jenkins actually provides that feature, this is called “Build history” and can be seen for the whole cluster or for some particular node. Unfortunately, when cluster is quite big (ours has more than 300 executors serving more than 10000 builds per day) Jenkins is not able to show the graph.

Vim. Insert mode

I gave a talk lately at DevClub about vim autocompletion out of the box and registers. Sorry, english-speaking friends, the talk is in Russian.

Postgresql. Export schema, rename and import

Lately as a process of joining different Postgres databases with 1 schema each into 1 database with different schemas, I had to export a schema from a database and to import it into another database with a different schema name.

OptionParser With Commands

Ruby standard library provides a good solution for parsing command line options passed to the script or application. It’s called OptionParser. It’s powerful and very easy to use. The code you have to write is easy to read and modify. It also supports different kind of options: short and long flags, required or optional arguments, also different types of arguments including dates, lists and so on.

Logging In Ruby

My work involvs writing many small command line applications (scripts) in ruby. One of the common things among them is logging. The application should produce adequate log messages, so that one could follow the application flow. Ruby has a very good logger in standard library. You can use it like that:

Testing Chef Cookbooks. Part 3: Integration Tests With Test Kitchen, Inspec, Lxd.

Testing your cookbooks with unit tests will help you not to break existing functionality. But how can you be sure that the recipe will successfully run on production node? The only answer to that is running this recipe on some other/similar machine and checking if everything is actually configured the way it must be. Don’t worry we will not need some additional hardware for testing cookbooks, it can comfortably be done in virtual machine or container.

Create an Lxd Container With Chef

Before going further to running integration tests on your cookbooks and roles we need to prepare a bit by creating an Lxd container, where we would run our tests. This is a script that creats an Lxd container with Chef installed and a running ssh server (required for Test Kitchen transport).