Personal Programming Notes

To err is human; to debug, divine.

Closures in Loop

In this post, we’ll look at a nasty gotcha with closures that can ensare even the most experienced programmers. This problem can happen to any programming language that has closures.

Minikube in Corporate VPN

If you are connected to corporate VPN via Cisco’s AnyConnect client, you might have problem with starting Minikube.

1
2
3
4
5
6
7
tdongsi$ minikube start --disk-size=50g --kubernetes-version=v1.8.0
Starting local Kubernetes v1.8.0 cluster...
Starting VM...
Downloading Minikube ISO
 140.01 MB / 140.01 MB [============================================] 100.00% 0s

^C

Github REST API Cookbook

The blog post shows some useful snippets for interacting with Github API. Jenkins pipelines regularly interacts with Github (public or Enterprise) API to perform some query/posting, for example, regarding the current pull request. For that reason, some of the following snippets are either in Groovy or curl commands embedded in Groovy-based Jenkinsfile code with some Jenkinsfile DSLs.

Jsonnet Code Recipes

If you are sending/working with lots of JSON data in files such as AWS CloudFormation templates, Jsonnet tool can help reducing the hassle of maintaining. Using Jsonnet templates, it is easier to organize data and reduce repeated code present in such JSON data. This post goes over a few common Jsonnet code recipes for generating JSON data.

Jenkins Pipeline Unit Testing

Jenkins shared library is a powerful way for sharing Groovy code between multiple Jenkins pipelines. However, when many Jenkins pipelines, including mission-critical deployment pipelines, depend on such shared libraries, automated testing becomes necessary to prevent regressions whenever new changes are introduced into shared librariers. Despite its drawbacks, the third-party Pipeline Unit Testing framework satisfies some of automated testing needs. It would allow you to do mock execution of pipeline steps and checking for expected behaviors before actually running in Jenkins. However, documentation for this third-party framework is severely lacking (mentioned briefly here) and it is one of many reasons that unit testing for Jenkins shared libraries is usually an after-thought, instead of being integrated early. In this blog post, we will see how to do unit testing for Jenkins shared library with the Pipeline Unit Testing framework.