CodeSOD: Continuous Installation

This post was originally published on this site

The Daily WTF

A recent code-review on a new build pipeline got Sandra‘s attention (previously). The normally responsible and reliable developer responsible for the commit included this in their Jenkinsfile:

sh ”’ if ! command -v yamllint &> /dev/null; then if command -v apt-get &> /dev/null; then apt-get update && apt-get install -y yamllint elif command -v apk &> /dev/null; then apk add –no-cache yamllint elif command -v pip3 &> /dev/null; then pip3 install –break-system-packages yamllint fi fi find . -name ‘*.yaml’ -exec yamllint {} ; || true find . -name ‘*.yml’ -exec yamllint {} ; || true ”’

So the goal of this script is to check to see if the yamllint command is available. If it isn’t, we check if apt-get is available, and if it is, we use that to install yamllint. Failing that, we try apk, Alpine’s package manager, and failing that we use pip3 to install it

To read the full article click on the 'post' link at the top.