bkcli
is an easy to use buildkite command line tool. Features include:
- Prints logs in
ANSI
color tail -f
style output for build logs- Trigger builds from the command line
- Check which steps failed for a build
- Uses config ini (
~/.bkcli/config
) to manage different tokens and orgs
- Download the latest release binary for your platform
- Make sure it's executable
- Move the binary to a folder in your
$PATH
For example, assuming /usr/local/bin
is in your $PATH
wget https://github.com/stellargraph/bkcli/releases/latest/download/bkcli-linux
chmod +x bkcli-linux
mv bkcli-linux /usr/local/bin/bkcli
wget https://github.com/stellargraph/bkcli/releases/latest/download/v0.0.2/bkcli-macOS
chmod +x bkcli-macOS
mv bkcli-macOS /usr/local/bin/bkcli
Currently untested
Install govendor
go get -u github.com/kardianos/govendor
Set the project in the $GOPATH/src
. In the repo folder, run govendor sync
or make sync
to pull down the packages in the vendor folder.
To compile run make linux
, for linux builds, make darwin
for MacOS builds, and make windows
for Windows builds (64-bit
architecture is assumed in all cases).
A buildkite token is needed to interact with buildkite's API.
Visit https://buildkite.com/user/api-access-tokens to create a token
The scopes the token needs for bkcli
:
read_agents
read_builds
read_build_logs
read_pipelines
write_builds
GraphQL API Access is not needed
bkcli
can read the token from the environment variavle BUILDKITE_TOKEN
or from a config file ~/.bkcli/config
. Note that the environment variable for the token takes precedence over the config file.
For the default buildkite organization, the command line argument --organization
takes precedence over the environment variable BUILDKITE_ORG
, then over the config file.
Use cases:
-
For automated runs of
bkcli
(or CI runs with the docker container), injecting the token as an environment variable would make sense. -
For personal tokens on local machines, using a config file is preferred. Inside your
$HOME
folder, create the~/.bkcli/config
with the content
[default]
token = xxxxxxxxxxxxxxxxxxxxx
organization = stellar
Note that other profiles can be selected with the --profile
flag.
bkcli --help
or just bkcli
will show the help output.
To get a log for a particular build
bkcli -p <pipeline> -b <build number>
For a particular commit hash
bkcli -p <pipeline> -c <commit hash>
To tail -f
a running job, use the -f
flag
To re-trigger the last build in a pipeline
bkcli -p <pipeline> -t
To re-trigger a particular build
bkcli -p <pipeline> -b <build number> -t
bkcli -a
Will return in JSON
format for parsing
To get a tail of the log of a particular git repo after a commit has been made
alias getlog='bkcli -c $(git rev-parse HEAD) -p $(basename $(git rev-parse --show-toplevel)) -f'
note that it assumes the repo name is the same as the pipeline name
To use the remote origin url
alias getlog='bkcli -c $(git rev-parse HEAD) -p $(basename -s .git $(git config --get remote.origin.url)) -f'
For bash/zsh completions, add the code snippet to your relevant dotfile, e.g., ~/.bash_profile
For bash
eval "$(bkcli --completion-script-bash)"
For zsh
eval "$(bkcli --completion-script-zsh)"
To build the image stellargraph/bkcli
run ./docker/build.sh
, or pull the latest image docker pull stellargraph/bkcli
To use a token with the docker image, inject the token as the environment variable BUILDKITE_TOKEN
GitHub issue submissions and pull requests and are welcome