2 releases
Uses old Rust 2015
0.1.2 | Nov 30, 2018 |
---|---|
0.1.1 | Nov 29, 2018 |
#11 in #jenkins
17KB
293 lines
jenq
Query for jenkins history for parametrised jobs.
Authentication
Set evars to authenticate with jenkins:
export JENKINS_URL=https://jenkins.domain.invalid
export JENKINS_API_TOKEN=API_TOKEN_FROM_USER_PAGE
export JENKINS_API_USER=user.name
The user only requires read access to the jobs you want to query.
Usage
Ask jenq
for history
, latest
, or console
for a named job, optionally specifying filters:
jenq history myjobname -f APP:myapp -f VERSION=0.1.2
jenq console myjobname -f APP:myapp
jenq latest myjobname
Filters can work in all subcommands, and match jenkins StringParameters. Here myjobname
is assumed to have two string parameters: APP
, and VERSION
.
The history
example above gets history where both values of the parameters match.
The console
example above gets the latest console output where the APP
parameter matches.
The latest
example above gets the latest job number from jenkins without matching anything.
jenq history
Creates a table of last matching jobs (gaps in numbers caused by filters):
BUILD UPDATED RESULT
189 2018-11-27 20:09:44 Some(Success)
182 2018-11-26 17:22:24 Some(Success)
160 2018-11-23 15:33:33 Some(Success)
130 2018-11-22 12:08:15 Some(Success)
Note: the build numbers are underlined, clickable links in your terminal if your terminal emulator supports it.
jenq latest
Produces a link and information about last build matching your parameters:
myjobnames#189 (478354) at 2018-11-27 20:09:44 UTC on https://jenkins.domain.invalid/job/myjobname/189/
jenq console
Get the raw console output of the latest matching job, or numbered job:
jenq console myjobname
jenq console myjobname 32
Produces the raw console output, along with the expected jenkins gunk (here truncated):
Started by upstream project "myjobname" build number 32
originally caused by:
Started by remote host 1.1.1.1
[EnvInject] - Loading node environment variables.
....🐘.....
shipcat::kube: Waiting 65s for deployment webapp to rollout (not ready yet)
shipcat::helm::direct: successfully rolled out webapp
Finished: SUCCESS
Installation
Latest stable with rust installed:
cargo install jenq # latest stable
Latest stable without rust installed (linux only):
JENQ_VERSION=0.1.1
curl -sSL https://github.com/clux/jenq/releases/download/${JENQ_VERSION}/jenq.x86_64-unknown-linux-musl.tar.gz | tar xz -C /usr/local
Substitute JENQ_VERSION
variable for the version you want.
Autocompletion
Add this to your ~/.bash_completion
file:
if hash jenq 2> /dev/null; then
source <(jenq completions bash)
fi
Development
Clone and build:
git clone git@github.com:clux/jenq.git && cd jenq
cargo build
ln -sf $PWD/target/debug/jenq /usr/local/bin/jenq
License
Apache 2.0 licensed. See LICENSE for details.
Derivative work from shipcat 0.74.0 licensed under Apache 2.0
Dependencies
~29MB
~567K SLoC