Build Jenkins jobs effortlessly using a single command. 🚀
Project description
jenkinsctl
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
.. |PyPI-Downloads| image:: https://img.shields.io/pypi/dm/shtab.svg?label=pypi%20downloads&logo=PyPI&logoColor=white :target: https://pepy.tech/project/shtab :alt: Downloads
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for jenkinsctl-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4d693a7551e613820b3010b5618734bd9e240ddeef3ab533f5ed99b4c6c48b5 |
|
MD5 | c8d342361e8f8c2c95df2ea61bb801ea |
|
BLAKE2b-256 | 5584b7d8037b8e86b31b34ca4bbf3696bf37683bb7e1f43aa30f7776ae547f01 |