buildkite / cli

A command line interface for Buildkite.
MIT License
169 stars 44 forks source link

Environment Variable config #408

Closed moskyb closed 1 day ago

moskyb commented 1 day ago

This PR: Allows users to specify their buildkite API tokens and organization slugs via environment variable, allowing them to end-run around the bk configure command. This should make running the bk cli in headless environments (like CI jobs 👀) much easier.

Environment variables take precedence over config items specified in files, as is fairly standard across CLI tools.

Example:

$ rm ~/.config/bk.yaml
$ export BUILDKITE_API_TOKEN=bkua_haha_nice_try 
$ export BUILDKITE_ORGANIZATION_SLUG=bennos-extra-secret-org 
$ bk pipeline view "my-cool-pipeline"
  My Cool Pipeline: Possibly the coolest pipeline around
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

                         Speed: 11s    Reliability: 80%

    agents:
      queue: default

    steps:
      - command: buildkite-agent pipeline upload

Additionally, it adds another envar for BUILDKITE_REST_API_HOST, similar to the graphql host envar added in #406. This should make local development easier.

🍷🧀 This PR should pair with #407 nicely - they allow gradations in how interactive you want CLI configuration to be