- Go 93.6%
- Shell 6.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| cmd/jrun | ||
| internal/jenkins | ||
| go.mod | ||
| go.sum | ||
| jenkins.sh | ||
| jrun.conf.example | ||
| LICENSE.txt | ||
| README.md | ||
A simple Jenkins client
Jrun aims to be a simple client for the Jenkins API. It allow to trigger Jenkins builds remotely and returns the Jenkins Console output to the local terminal.
Build and Installation
There are no distributable packages yet. You need a decent Golang installation (I used Go 1.20.2, but 1.16.x and onwards should be fine.)
The short route
Use Golang's install tool directly:
go install go.schlittermann.de/heiko/jrun/cmd/jrun@latest
This installs the binary to the directory pointed to by the GOBIN
environment variable. (See go help env.). You may need to set the
GONOPROXY environment to go.schlittermann.de in case of rapid
development cycles.
The developer route
Clone the Git repo and install it from inside the cloned repo:
go install ./cmd/jrun
The GOBIN environment variable can/should be used here too.
Usage
Jrun uses a configuration file .jrun.conf in your current directory.
The example config can be printed using
jrun -example-config
Once you configured it for your needs, you can use
jrun -running-config
to check what Jrun reads from your config.
For available command line options, please refer to the output of
jrun -h
Authentication to the Jenkins server
You need 2 types of authentication credentials.
-
Your username and password (optionally an API token, you generated in your Jenkins user profile's settings.)
-
A build token, which you need o create in your pipeline's configuration (pipeline -> configuration -> build triggers -> trigger builds remotely).
Implementation notes
That's nothing, 3…4 lines Curl wouldn't do in the same manner. But I felt, that using Golang enforces stricter style. And it's more joy (at least for me) using Golang.
References
- https://docs.cloudbees.com/docs/cloudbees-ci-kb/latest/client-and-managed-masters/get-build-number-with-rest-api
- https://gist.github.com/t3knoid/77a8903d79ff65194d06a610ec4a6b4b
- https://stackoverflow.com/questions/17792023/jenkins-retrieve-full-console-output-during-build-step
- https://github.com/r-hub/jenkins-log-stream/blob/master/index.js