Using Steampipe in a GitLab CI/CD Pipeline

GitLab provides a hosted environment in which you can build, test, and deploy software. This happens in a GitLab Runner. Let's install Steampipe into a shared runner on gitlab.com, then install a plugin and run a query.

Installing Steampipe in a GitLab Runner

To run scripts when you push changes to a gitlab.com repo, you place them in a file called .gitlab-ci.yml. Here's an example that installs Steampipe into the runner's environment.

The official command to install Steampipe begins with sudo. That isn't necessary here, though, because in this environment you already are the root user.

Running Steampipe in a GitLab Runner

Steampipe cannot, however, run as root. So we'll create a non-privileged user, and switch to that user in order to run Steampipe commands. Our first command will install the Hacker News plugin.

Next, we'll add a file called hn.sql file to the repo.

Finally, we'll copy hn.sql into the home directory of the non-privileged user, then run a query.

That's it! Now you can use any of Steampipe's plugins to enrich your GitLab pipelines.