Skip to main content

A command-line tool to interact with Jenkins jobs 🚀

Project description

jenkinsctl

jenkinsctl PyPI version Downloads License: GPL v3

Build Jenkins jobs effortlessly using a single command. 🚀

Installation 📦

pip 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

Usage 🤖

$ jenkinsctl --help
usage: jenkinsctl [-h] {build,config} ...

options:
  -h, --help      show this help message and exit

Subcommand:
  {build,config}
    build         run new build
    config        get config of a build

Run a Jenkins Job

$ jenkinsctl build --help
usage: jenkinsctl build [-h] [-f FILE] [-v] [-s SUPPRESS_LOGS] [--param PARAM]

options:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  Yaml configuration file
  -v, --verbose
  -s SUPPRESS_LOGS, --suppress-logs SUPPRESS_LOGS
  --param PARAM

Get Config of a Jenkin Build in YAML Format

$ jenkinsctl config --help
usage: jenkinsctl config [-h] job_name build_no

positional arguments:
  job_name
  build_no

options:
  -h, --help  show this help message and exit

Examples 🎭

Runing a Jenkins Job

Create a YAML configuration file, let's say my_job.yaml, with job parameters like this:

job: my_job
params:
    param1: some value
    param2: 10
    param3: true

Initiate the job build using the following command:

jenkinsctl build -f my_job.yaml

This command executes the job based on the specified YAML configuration.

Overriding Specific Parameter from Configuration

jenkinsctl build -f my_job.yaml --param param2=11 --param param3=false

This command will override the value of param2 and param3 from original configuration file my_job.yaml, passing an effective configuration as follows to run jenkin job :

job: my_job
params:
    param1: some value
    param2: 11
    param3: false

Generating Config from Existing Builds

Capture and reproduce configurations from previous Jenkins builds. To generate a YAML configuration file from a specific build (e.g. 2nd build) of a job (e.g., my_job), use the following command:

jenkinsctl config my_job 2 > my_job.yaml

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.0.tar.gz (21.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.0-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jenkinsctl-1.0.0.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-48-generic

File hashes

Hashes for jenkinsctl-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4e604436913ddec938908e1a189a711a8f77c1b80a14129ca8dc641bc5908dfa
MD5 ed966c8dfee3f572a8f43df76c15a804
BLAKE2b-256 3c55c807abc7ad02cf7d78e46c7467f9a92ac72386d0418882acdd522c079dc6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jenkinsctl-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-48-generic

File hashes

Hashes for jenkinsctl-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0bcf784153de4ac85f54f0c9f2a187f9cca3e79df8c5cf586bad3fffd3ec9ca5
MD5 88577b6adc0012e0373c8b0eec5c34ea
BLAKE2b-256 112b52375850b84f88d7ae78b637822e4b0da4c6eae5151ffac7e01ed1a054b1

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