Skip to main content

Pipelines Installation

In this section, you will find how to install STK CLI in a pipeline.


To install and authenticate STK CLI in a pipeline, you need a StackSpot Enterprise account.

Requirements

See below the requirements:

info

The installation is still possible without an Enterprise account, but you won't have access to exclusive resources.

Installation on your own runner**

1. Configure environment variables

To ensure the correct functioning of the STK CLI, especially in the runners of your pipeline. Configure the following environment variables in your pipeline:

LANG: C.UTF-8
LANGUAGE: C.UTF-8
LC_ALL: C.UTF-8
PYTHONIOENCODING: utf-8

Check the documentation for your CI/CD service:

Also configure the environment variables on your system:

  1. On the taskbar, search for "variables" and access the "Edit environment variables" option;
  2. In the open window, click on the "New..." option. Then, fill in the name and value of the variable and click "OK";


The name and value of the variables follow the pattern below:

NAME: variable-Value

Example:

Variable name: NAME

Variable value: variable-Value


Repeat filling for all variables below:

LANG: C.UTF-8
LANGUAGE: C.UTF-8
LC_ALL: C.UTF-8
PYTHONIOENCODING: utf-8

2. Install packages on your runner

Install the following packages on your runner:

  • jq;
  • curl;
  • git.

Example:

See the installation of the jq tool on a Linux runner on GitHub:

name: Build on Ubuntu
on: push

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Install jq tool
run: |
sudo apt-get update
sudo apt-get install jq

For more examples, visit the GitHub documentation on customizing runners.

Install via curl on the pipeline

Use in your pipeline the code in the steps below to install StackSpot:

curl -fsSL https://stk.stackspot.com/install.sh | bash && exec $SHELL

Example:

pipeline step example.
steps:
- name: Install StackSpot
run: |
curl -fsSL https://stk.stackspot.com/install.sh | bash && exec $SHELL
warning

Installing via curl also works for local usage, but only in Unix systems, like Linux and MacOS.

Authenticate via CI/CD

The Enterprise account supports the STK CLI authentication via the command line, using a client id and a client key.

This kind of authentication allows you to have an active session, and you can configure the expiration time to use STK CLI via the command line, for example, in CI/CD pipelines.

warning

The session expiration time is 20 minutes. You can configure this time soon via the StackSpot Portal.

Get keys and authenticate in your pipeline

To authenticate via the pipeline, you must get the keys in the StackSpot Platform. Afterward, you must inform them with the stk login command. To do that, follow the steps below:

Step 1. Log in the StackSpot Platform;

Step 2. On the first page, access the Manage Account page and then, click Access Tokens;

Step 3. Authorize the Token usage and click 'Generate Tokens'.

Authorize Access Token page

Generate the Client ID and Client Key
warning

Keys are generated per user of the organization. If a user generates a new key, the previous one will automatically become invalid. Generating a new key does not invalidate the keys of other users in that organization.

Step 4. In your pipeline, execute the command below, replacing the values between quotes with the new values you got in the previous step:

info

Add the command below with the < >

stk login --client-id <ID> --client-key <KEY> --realm <REALM>
tip

Register your Token as a secret in Action on GitHub

Example:

  • Client ID as CLIENT_ID in the secret;
  • Client Key as CLIENT_KEY in the secret;
  • Realm as CLIENT_REALM in the secret;
GitHub Actions Secrets

Use in your pipeline:

pipeline step with GitHub secrets example
steps:
- name: Config login
with:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_KEY: ${{ secrets.CLIENT_KEY }}
CLIENT_REALM: ${{ secrets.CLIENT_REALM }}

For more details, follow the secrets usage on the GitHub Actions documentation.

Running the STK CLI with GitHub-hosted runners

If you will be using a GitHub-hosted runner to run the STK CLI in your workflow, use the following example in your pipeline file:

  1. Set up GitHub Secrets.
  2. [Optional] Add any STK CLI commands you need.
  3. [Optional] Change the name: Run CLI Commands field to change the name of the Workflow and the on: [push] field to change when it runs.
Example installation on pipeline with GitHub-hosted runner 'ubuntu-latest'
name: Run CLI Commands

on: [push]

jobs:
deploy:
runs-on: ubuntu-latest
env:
LANG: C.UTF-8
LANGUAGE: C.UTF-8
LC_ALL: C.UTF-8
PYTHONIOENCODING: utf-8

steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Download STK CLI
shell: bash
run: |
curl \
--fail \
--http2-prior-knowledge \
--location \
--output /tmp/stk.deb \
--silent \
--show-error \
--tlsv1.3 \
https://stk.stackspot.com/installer/linux/stk.deb

- name: Install STK CLI
shell: bash
run: |
sudo dpkg --install /tmp/stk.deb || echo "Installation failed with exit code: $?"

- name: Authenticate StackSpot
run: |
$HOME/.stk/bin/stk login --client-id ${{ secrets.CLIENT_ID }} --client-key ${{ secrets.CLIENT_KEY }} --realm ${{ secrets.CLIENT_REALM }}

Next Steps