Skip to content

coreos/coreos-ops-assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CoreOS Operations Assistant

This is an AI-powered assistant used by the CoreOS team to make operations (such as pipeline monitoring) easier. It works in Slack or Matrix.

The assistant listens for direct mentions in a chat channel in which it was invited.

Setup

Local Python Environment

  1. Install dependencies:

    source env/bin/activate  # if using a virtualenv
    pip install -r requirements.txt
    
  2. Set environment variables:

For Jenkins:

*   `JENKINS_URL`: The URL of your Jenkins server.
*   `JENKINS_TOKEN`: Your Jenkins token (often an API token).

If using Slack:

*   `SLACK_BOT_TOKEN`: Your Slack bot token.
*   `SLACK_APP_TOKEN`: Your Slack app token.

If using Matrix:

*   `MATRIX_SERVER`: Your homeserver (i.e.  https://matrix.org)
*   `MATRIX_ACCESS_TOKEN`: Your device access token
*   `MATRIX_ROOM`: Your room FQDN (i.e. `#tmp-coreos-pipeline-assistant-testing:matrix.org`)

If using GEMINI:

*   `GEMINI_API_KEY`: (OPTIONAL) Your Gemini API key.

If using OpenRouter:

*   `OPENROUTER_API_KEY`: (OPTIONAL) Your OpenRouter access key

Usage

  1. Run the bot:

    source env.sh            # tokens env vars
    source env/bin/activate  # if using a virtualenv
    python main.py
    
  2. Invite the bot to your channel.

  3. Mention the bot in a thread of a Jenkins failure notification. The bot will then reply with a summary of the failure.

Running with Podman

  1. Build the container image:

    podman build -t coreos-ops-assistant .
    
  2. Run the container: You can pass the environment variables directly with the -e flag, or you can use a .env file.

    Using the -e flag:

    # First export the appropriate variables in your environment based
    # on what you are using (i.e. slack/matrix and gemini/openrouter)
    export SLACK_BOT_TOKEN='your_bot_token'
    export SLACK_APP_TOKEN='your_app_token'
    export MATRIX_SERVER='https://matrix.org'
    export MATRIX_ACCESS_TOKEN='your_app_token'
    export MATRIX_ROOM='your_room_fqdn'
    export JENKINS_URL='https://your.jenkins.url'
    export JENKINS_TOKEN='your_jenkins_token'
    export GEMINI_API_KEY='your_api_key'
    export OPENROUTER_API_KEY='your_api_key'
    
    # Now run `podman` and it will pull the values from the variables
    # already set in your environment.
    podman run -it --rm        \
      -e SLACK_BOT_TOKEN       \
      -e SLACK_APP_TOKEN       \
      -e MATRIX_SERVER         \
      -e MATRIX_ACCESS_TOKEN   \
      -e MATRIX_ROOM           \
      -e JENKINS_URL           \
      -e JENKINS_TOKEN         \
      -e GEMINI_API_KEY        \
      -e OPENROUTER_API_KEY    \
      coreos-ops-assistant
    

    Using a .env file: Create a file named .env with the following content:

    SLACK_BOT_TOKEN=your_bot_token
    SLACK_APP_TOKEN=your_app_token
    MATRIX_SERVER=https://matrix.org
    MATRIX_ACCESS_TOKEN=your_app_token
    MATRIX_ROOM=your_room_fqdn
    JENKINS_URL=https://your.jenkins.url
    JENKINS_TOKEN=your_jenkins_token
    GEMINI_API_KEY=your_api_key
    OPENROUTER_API_KEY=your_api_key
    

    Then run the container with the --env-file flag:

    podman run -it --rm --env-file .env coreos-ops-assistant
    

Testing

To run the unit tests, run the following command from the root of the project:

python3 test.py

About

An AI-powered assistant to help monitor CoreOS pipelines

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •