Using Steampipe in CircleCI

CircleCI provides a hosted environment in which you can build, test, and deploy software. It integrates with services such as GitHub, GitLab and Bitbucket to listen to events that trigger pipelines or consume source code. Here we integrate a GitLab project with CircleCI to install Steampipe, then install a plugin and run a query.

Installing Steampipe in CircleCI

To run scripts, first connect your GitLab repository to CircleCI and create a config.yml file that contains the definitions of the Pipeline. Here's an example that installs Steampipe.

version: 2.1
jobs:
install:
machine: true
steps:
- checkout
- run: echo "Hello, let's install Steampipe!"
- run: sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/turbot/steampipe/main/install.sh)"
workflows:
my-workflow:
jobs:
- install

Running Steampipe in CircleCI

In order to run Steampipe commands, we will first install the Hacker News plugin.

version: 2.1
jobs:
install:
machine: true
steps:
- checkout
- run: echo "Hello, let's install Steampipe!"
- run: sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/turbot/steampipe/main/install.sh)"
- run: 'steampipe plugin install hackernews'
workflows:
my-workflow:
jobs:
- install
gitlab-plugin-installed

Next, we'll update the file with a query to fetch the top 10 stories from hackernews_best.

version: 2.1
jobs:
install:
machine: true
steps:
- checkout
- run: echo "Hello, let's install Steampipe!"
- run: sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/turbot/steampipe/main/install.sh)"
- run: 'steampipe plugin install hackernews'
- run: 'steampipe query "select id, title, score from hackernews_best order by score desc limit 10"'
workflows:
my-workflow:
jobs:
- install
gitlab-query-output

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