A Go CLI application that integrates with the Jenkins API to retrieve build information and generate build reports.
This project is part of my Go learning journey focused on DevOps, Platform Engineering, Cloud Infrastructure, and Automation.
Build a Jenkins reporting tool while learning practical Go concepts used in real-world platform engineering and infrastructure tooling.
- Integrate with the Jenkins REST API
- Support Jenkins authentication using environment variables
- Use HTTP Basic Authentication
- Accept Jenkins API endpoint URL as a command-line argument
- Parse Jenkins API responses into Go structs
- Generate formatted build reports
- Handle HTTP request errors gracefully
- Handle HTTP response validation
- Handle JSON parsing errors gracefully
- Validate command-line input
- Organize code using reusable Go packages
- Separate application logic from business logic
- Structs
- JSON
- Struct Tags
- json.Unmarshal
- File Reading
- Error Handling
- Packages
- Separation of Concerns
- Exported Functions
- Code Organization
- Reusable Components
- net/http
- HTTP Clients
- HTTP Requests
- HTTP Response Handling
- Response Body Processing
- API Communication
- Status Code Validation
- Conditional Logic
- Business Rules
- if / else if Statements
- Status Mapping
- Fallback Handling
- User-Friendly Reporting
- os.Args
- Command-Line Applications
- CLI Input Validation
- Runtime Configuration
- User Input Handling
- Parameterized API Requests
- Slices
- JSON Arrays
- Collection Processing
- Aggregation
- Statistics Generation
- map[string]int
- Counting and Grouping Data
- Iterating Over Collections
- os.Getenv()
- Environment Variables
- Basic Authentication
- HTTP Request Construction
- http.NewRequest()
- req.SetBasicAuth()
- Secure Configuration
- Runtime Credential Management
- Jenkins API Integration
- API Contract Mapping
- Production-Style Tooling
- External System Integration
- Real API Consumption
- Build Metadata Processing
Parse build information from a JSON file. ✅
Move logic into reusable packages. ✅
Fetch build data using HTTP APIs. ✅
Generate build status summaries. ✅
Accept input using command-line arguments. ✅
Support multiple build reports. ✅
Add Jenkins authentication. ✅
Integrate with a real Jenkins API. ✅
jenkins-build-report-tool/
├── main.go
├── client/
│ └── jenkins.go
├── models/
│ └── build.go
├── README.md
├── .gitignore
└── go.mod
Linux/macOS:
export JENKINS_USER=my-user
export JENKINS_TOKEN=my-tokenWindows PowerShell:
$env:JENKINS_USER="my-user"
$env:JENKINS_TOKEN="my-token"go run main.go "<jenkins-api-url>"Example:
go run main.go "https://jenkins.example.com/job/service-a/456/api/json"{
"fullDisplayName": "service-a #456",
"number": 456,
"result": "SUCCESS",
"duration": 180000
}Build Report
Job Name : service-a
Build No : 456
Status : SUCCESS
Duration : 180.00 sec
go fmt ./...
go build ./...- Valid Jenkins credentials
- Missing JENKINS_USER
- Missing JENKINS_TOKEN
- Invalid credentials (401)
- Missing CLI argument
- Invalid URL
- Jenkins unavailable
- Invalid JSON response
- Non-200 HTTP response
- Successful Jenkins API response
| Variable | Description |
|---|---|
| JENKINS_USER | Jenkins username |
| JENKINS_TOKEN | Jenkins API token or password |
- Go
- net/http
- JSON
- Basic Authentication
- Environment Variables
- CLI Arguments
- REST APIs
Through this project I practiced:
- Building CLI applications in Go
- Designing reusable packages
- Working with JSON APIs
- Consuming REST endpoints
- Implementing authentication
- Managing runtime configuration
- Handling errors idiomatically
- Integrating with external systems
- Building production-style infrastructure tooling
v0.8.0