https://github.com/davidrr-f/jenklog
Jenkins Build Log Querying CLI Tool
https://github.com/davidrr-f/jenklog
cli golang-cli jenkins logging
Last synced: 2 months ago
JSON representation
Jenkins Build Log Querying CLI Tool
- Host: GitHub
- URL: https://github.com/davidrr-f/jenklog
- Owner: DavidRR-F
- License: other
- Created: 2024-05-24T20:24:54.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-16T19:01:53.000Z (over 1 year ago)
- Last Synced: 2025-03-24T00:41:21.408Z (over 1 year ago)
- Topics: cli, golang-cli, jenkins, logging
- Language: Go
- Homepage:
- Size: 6.48 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Jenklog
I often use the jenkins cli as part of my jenkins management workflow. There is one
subcommand I always want to use but then I remember that it is horrible to work with
`jenkins-cli console`. This command is grabs the build logs of a specified pipeline
and presents them in your terminals stdout. There are two issues I have with
this subcommand. One, the encoding is wonky so I will often try and `awk` a
specific subset of the logs to no avail. Second, it only gets one build log at a time
and you have to reference that build by its build id, aka an incrementing number
no one is keeping track of so you have to open up the gui and check the run
anyways which defeats the purpose.
So I made a simple cli tool with more verbose options to grab build logs from
jenkins that you can actually pipe a `grep` too without losing what little hair
you probably have left since your probably managing a jenkins instances. Enjoy
#### ***Required Jenkins Plugins***
- ***Pipeline***
- ***Pipeline: Stage View***
# Commands
## Jenklog Auth
```bash
jenklog auth [url] [flags]
```
| Flags | Description | Required |
|:-------|:------------|:--------|
| -t --token | Jenkins authentication token | yes |
| -u, --user | Username asociated with authentication token | yes |
## Jenklog Job
```bash
jenklog job [jobName] [flags]
```
| Flags | Description | Required | Default |
|:-------|:------------|:--------|:--------|
| -b, --build | Job Build Number | no | last |
| -s, --stage | Specific Pipeline Stage Name to get | no | all |
| -p, --prev-count | Number of Build Logs to query preceding the specified build | no | 0 |
### Examples
1. Get Stage Logs from Latest Build
```bash
> jenklog job testy -s Test
ID: lastBuild
Stage: Test
[Pipeline] echo
Testing...
```
2. Get Last Failed
```bash
> jenklog job testy -b lastFailedBuild
ID: lastFailedBuild
[Pipeline] bat
ERROR: NO BAT THIS IS A LINUX AGENT
```
3. Get Build Log 5-3
```bash
> jenklog job testy -b 5 -p 2 -s Test
ID: 5
Stage: Test
[Pipeline] echo
Testing...
ID: 3
Stage: Test
[Pipeline] echo
Testing...
```
### TODO
- [ ] Better Auth Types
- [ ] Jenkins Syslog Querying