Skip to main content

A command-line tool to interact with Jenkins jobs 🚀

Project description

jenkinsctl

jenkinsctl PyPI version Downloads License: GPL v3

jenkinsctl – Jenkins Control Right from Your Terminal 🚀

jenkinsctl is a CLI tool that puts Jenkins management right in your terminal. It simplifies tasks like listing builds, fetching logs, and triggering parameterized jobs—no more web UI hassle!

Why jenkinsctl? 🔥

Jenkins workflows can be tedious through the web UI. jenkinsctl keeps your hands on the keyboard, streamlining Jenkins management directly from your terminal, making it perfect for quick job control, scripting, and automation.


Key Features

  • Quick Build Listings: View recent builds for any job.
  • Instant Log Access: Fetch build logs effortlessly.
  • JSON & YAML API Data: Retrieve job configurations and build data in JSON or YAML.
  • Easy Rebuilds: Re-run jobs without reopening Jenkins.
  • Parameterized Builds: Customize builds with dynamic parameters.
  • Folder Job Listings: Organize and access jobs in specific folders.
  • Autocompletion: Enhance the CLI experience with shell autocompletion for bash, zsh, or fish.

Installation 📦

pip3 install jenkinsctl

Jenkins Configuration 🛠️

Before using jenkinsctl, configure your Jenkins server details in your shell profile. Add these lines in your ~/.bashrc or ~/.zshrc file:

export JENKINS_SERVER_URL=http://localhost:8080
export JENKINS_USERNAME=amanshaw4511
export JENKINS_API_KEY=21df49caf41726094323b803a6de363eae

Adjust the values to match your Jenkins server's URL, your username, and the corresponding API key. This configuration is essential for jenkinsctl to interact with Jenkins and execute tasks efficiently.

How to Get the API Token: https://www.baeldung.com/ops/jenkins-api-token

Reload your shell profile:

exec $SHELL

Commands & Options 🤖

All jenkinsctl commands are designed to be terminal-friendly with structured flags and arguments.

list

List recent builds of a Jenkins job.

jenkinsctl list <job_name> [-n <number_of_builds>]
Option Description
job_name Name of the Jenkins job
-n, --number Number of builds to list (default: 5)

logs

View logs of a specific build.

jenkinsctl logs <job_name> [build_no]
Option Description
job_name Name of the Jenkins job
build_no Build number (optional, defaults to last build)

json

Get JSON API data for a build.

jenkinsctl json <job_name> [build_no]

config

Get build configuration in YAML format.

jenkinsctl config <job_name> [build_no]

rebuild

Trigger a rebuild of a specific job.

jenkinsctl rebuild <job_name> [build_no]

build

Start a new build using YAML configuration with optional parameters.

jenkinsctl build -f <config_file> [--param key=value]
Option Description
-f, --file YAML configuration file for the Jenkins job
--param Key-value pairs to override config parameters

enable-completion

Enable shell autocompletion for streamlined CLI use.

jenkinsctl enable-completion [shell]
Argument Description
shell Optional: specify shell (bash, zsh, or fish)

jobs

List all jobs in a specified Jenkins folder.

jenkinsctl jobs [folder_name]
Option Description
folder_name Folder path for jobs (optional)

Quick Examples 🎭

  1. List Recent Builds: Show the last 10 builds for a job.

    jenkinsctl list my-awesome-job -n 10
    
  2. Get Logs for a Build: View logs for a specific build.

    jenkinsctl logs my-awesome-job 42
    
  3. Start a Build with Parameters: Launch a build with custom parameters.

    jenkinsctl build -f path/to/config.yaml --param version=1.2.3
    

Contributing 🤝

Contributions are welcome! If you want to contribute, fork the repo, make your changes, and submit a pull request. Found an issue? Open an issue in the repo!


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jenkinsctl-1.0.5.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jenkinsctl-1.0.5-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file jenkinsctl-1.0.5.tar.gz.

File metadata

  • Download URL: jenkinsctl-1.0.5.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.13 Linux/6.5.0-1025-azure

File hashes

Hashes for jenkinsctl-1.0.5.tar.gz
Algorithm Hash digest
SHA256 9f3aed4362c1a70499b356821bcb4c3263774258e37f4038e1c2edc1c4cabd80
MD5 ceba47c2d99259dbeb01196d268c9a6f
BLAKE2b-256 6d3c6d047d70ccd66f157916dcc3f27dc701bb3c65d91261ed69137b2f114bba

See more details on using hashes here.

File details

Details for the file jenkinsctl-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: jenkinsctl-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 25.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.13 Linux/6.5.0-1025-azure

File hashes

Hashes for jenkinsctl-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0e614715720860686f67c6d8dbe4bcfe2e2026f06a4b9e7ab18d9c58e5457792
MD5 7a8a432dd1df20ba2351e0ca4789cea7
BLAKE2b-256 c51813ce624382978bd47bc37a5c614f9d861ed504cec64dd320d6891841c81f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page