Laur IVAN

Build a Django Docker Image with Cx-Oracle

Posted by in Software, Tutorial

TL;DR: Don’t use alpine images. There’s a glibc issue. We added a cx-oracle dependency to one of our django apps. As the previous image was just an alpine basic (python) image we needed to put in place a process to build the new image. Initially, I’ve tried to use the same alpine image (oh, the slimmed down size is sooo tempting), but then I’ve hit a bunch of “Unknown symbol” messages when I’ve ran the install of cx-oracle in the docker build process. Subsequently, I’ve had to switch to python:3.6-slim-jessie….read more

Execute a Command in Every Directory with Bash

Posted by in Software, Tutorial

TL;DR: Use a find-based loop The other day I was wondering how to execute a command in each sub-directory of a project. In python, you have os.walk. In C, I would’ve probably written myself something just for fun etc. In shell, I know you have find which is capable of finding all directories (find (dir) -type d). All I need to do is to wrap this in a loop and for this one has two options: Commmand line style

or

Script style with a loop

The choice…read more

Build Update Statements with Oracle SQL Developer and Python

Posted by in Software, Tutorial

By default, SQL Developer can only export INSERT statements. This is quite unfortunate when one needs to build UPDATE statements because their syntax is different. I’ve tried to use regexp to convert the statements but I didn’t find it not straight forward at all. So, I cam up with the following strategy: Export the data as JSON Use a python script (below) to write the statements The python script We first need to specify things like the DB Schema, table and the primary key:

Subsequently, I’ve defined a wrapper…read more

How to Develop Pipelines – Some Best Practices

Posted by in IT, Software

These days I’m developing a bunch of pipelines to automatise the build/deployment process. Here are some things I’ve learned: How to develop Initially, I’ve started developing the pipeline as any other program: Create a repository, fire my editor, write a Jenkinsfile and use the Pipeline script from SCM. While the result is exactly what you want to have at the end, the edit-deploy-run cycle becomes a chore and it’s quite unpleasant at the beginning (I had a bunch of typos for example), so DON’T. Instead, create a simple pipeline with…read more

Sending HTTP requests with Jenkins Pipelines

Posted by in Uncategorized

As part of the CI/CD process, we might need to communicate with some external services’ APIs (e.g. notifying elastic search of a new index alias). I found an easy way to do it: Using a jenkins plugin. Jenkins plugin Jenkins has a HTTP request plugin. If you install it (or have it installed), you have the ability to send HTTP requests to external servers from Jenkins. Fortunately, this plugin also plays wery well with pipelines. You can sent practically any (REST) command to a destination:

You can customisethe request…read more

An Initial CI/CD Pipeline

Posted by in IT

Release-based deployments are sort of nice in the sense that you plan, draw a line, prepare stuff and release one or more components at the same time. It however stalls feature deployments a lot (e.g. a nice feature can be implemented in say a day but the release is sheduled in a month). It also gives way to out-of-order releases to please the business. Agile (CI/CD) aims to alleviate some of these problems. Prerequisites As part of the transition process, one has to establish a stack. In my case, it’s…read more

Copy Files From B to C via A with SSH

Posted by in IT

The other day I had an interesting situation to solve: I have some data on machine B and I want it copied on machine C. However, machines B and C have no direct connection (known_hosts), but machine A can connect to B and C without password. It is obvious that one needs to use machine A as a proxy between B and C.

After a while thinking of tunnelling and using some sort of actual network proxy, I realised that I/O would also do the trick: We can have…read more

Run Restricted Groovy API in Jenkins

Posted by in IT, Tutorial

The more recent versions of Jenkins have improved on security. Unfortunately, a side-effect is that scripts which were running before would fail now. An example is:

… which would list the projects defined in Jenkins. Fortunately, you can have access to theis API via the In-process Script Approval plugin (which is installed by default). If the script (pipeline) is versioned or executed in the sandbox, then you’ll need to approve method by method. If the script is not versioned, then you have the option to execute it outside the…read more

Fix Missing In-process Script Approval in Jenkins

Posted by in IT, Tutorial

Normally, when you have a script or a method to be approved, you should see the In-process Script Approval entry in your Jenkins’ configuration: Unfortunately, the In-process Script Approval entry in Jenkins’ configuration is not always shown, even though we have items to be approved. I found that installing the Permissive Script Security and briefly enabling it would solve the problem. On linux (Ubuntu), you need to edit /etc/default/jenkins and add

Then, you need to restart Jenkins for the security plugin to be disabled. I executed one of the…read more

Bulk Change the Date on Photos

Posted by in Random, Tutorial

I’ve got a new camera and I forgot to update the date. Consequently, the first photos are taken on 01/01/2017 instead of 04/03/2018. Given that more than 100 photos were taken, it would be a pain to change them one by one. So, here are the steps I did update the date: Download exiv2. Just search for exiv2-0.26-msvc.tar.gz (0.26 was the most recent at the moment of writing). Open it and extract the relevant folder (\dist\2015\x64\dll\Release in my case) in a convenient place (e.g. C:\EXIV\) Open a command prompt to…read more