Using Steampipe in Jenkins

Jenkins provides a hosted environment in which you can build, test, and deploy software. This happens in a Jenkins Pipeline. Let's use a pipeline to install Steampipe, then install a plugin and run a query.

Installing Steampipe in a Jenkins pipeline

To run scripts, you first create a Jenkinsfile which is a text file that contains the definition of a Jenkins Pipeline. Here's an example that installs Steampipe.

pipeline {
agent any
stages {
stage("Install") {
steps {
sh "curl -s -L https://github.com/turbot/steampipe/releases/latest/download/steampipe_linux_amd64.tar.gz | tar -xzf -"
echo "installed steampipe"
}
}
}
}

Running Steampipe in a Jenkins pipeline

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

pipeline {
agent any
stages {
stage("Install") {
steps {
sh "curl -s -L https://github.com/turbot/steampipe/releases/latest/download/steampipe_linux_amd64.tar.gz | tar -xzf -"
echo "installed steampipe"
sh './steampipe plugin install hackernews'
}
}
}
}
gitlab-plugin-installed

Next, we'll update the file to include a query to fetch the top 5 stories from hackernews_top.

pipeline {
agent any
stages {
stage("Install") {
steps {
sh "curl -s -L https://github.com/turbot/steampipe/releases/latest/download/steampipe_linux_amd64.tar.gz | tar -xzf -"
echo "installed steampipe"
sh './steampipe plugin install hackernews'
sh './steampipe query "select id, title, score from hackernews_top order by score desc limit 5"'
}
}
}
}
gitlab-query-output

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