Skip to main content

Jenkins API management CLI and universal command wrapper package

Project description

ngen-j

GitHub PyPI

Jenkins API management CLI tool that also supports executing scripts from /usr/local/bin/ngen-j-*.

Installation

Install from PyPI:

pip install ngen-j

Or install from source:

pip install .

Usage

The ngen-j command provides:

  • Jenkins API management commands
  • Script execution from bundled scripts

Version

Check the version:

ngen-j --version
# or
ngen-j -V

Login

Save Jenkins credentials for easy access:

ngen-j login

The login command will:

  • Prompt for Jenkins URL
  • Ask for authentication method (username+token, username+password, or base64)
  • Save credentials to ~/.ngen-j/.env
  • Test the connection

After login, you can use Jenkins commands without setting environment variables each time.

Check Connection

Validate your Jenkins access and credentials:

ngen-j check

The check command will:

  • Test connection to Jenkins server
  • Verify authentication credentials
  • Display Jenkins version and basic info
  • Show troubleshooting tips if connection fails

Examples:

ngen-j login                    # Setup Jenkins credentials
ngen-j check                    # Validate connection
ngen-j --version               # Check version
ngen-j jobs                     # List all jobs
ngen-j job my-job               # Get job details
ngen-j job --last-success       # Get last 10 successful jobs
ngen-j job --last-failure       # Get last 10 failed jobs
ngen-j build my-job             # Trigger build
ngen-j build my-job --param REF_NAME=develop REF_TYPE=branch  # Build with parameters
ngen-j build my-job --param=REF_NAME=develop --param=REF_TYPE=branch  # Alternative format
ngen-j get-xml my-job           # Get job XML config
ngen-j create my-job job.xml    # Create job from XML
ngen-j create my-job job.xml --force  # Update existing job
ngen-j delete my-job            # Delete job (with confirmation)
ngen-j delete my-job --force    # Delete job without confirmation

Jenkins API Management

Manage Jenkins jobs and builds using environment variables for authentication.

Environment Variables

Set the following environment variables for Jenkins authentication:

export JENKINS_URL="https://jenkins.example.com"
export JENKINS_USER="your-username"
export JENKINS_TOKEN="your-api-token"

Alternatively, you can use base64 encoded authentication:

export JENKINS_URL="https://jenkins.example.com"
export JENKINS_AUTH="base64-encoded-user:token"

Jenkins Commands

List all jobs:

ngen-j jobs

Get job details:

ngen-j job <job-name>

Get last 10 successful jobs:

ngen-j job --last-success

Get last 10 failed jobs:

ngen-j job --last-failure

Trigger a build:

ngen-j build <job-name> [--param KEY=VALUE ...] or [--param=KEY=VALUE ...]

Options:

  • --param KEY=VALUE - Pass build parameters (can be used multiple times)
  • --param=KEY=VALUE - Alternative format for build parameters

Examples:

ngen-j build my-job
ngen-j build my-job --param REF_NAME=develop REF_TYPE=branch
ngen-j build my-job --param=REF_NAME=develop --param=REF_TYPE=branch
ngen-j build my-job --param REF_NAME=develop --param=REF_TYPE=branch --param DEPLOY_ENV=staging

Get build console output:

ngen-j log <job-name> <build-number>

Get job XML configuration:

ngen-j get-xml <job-name>

Create or update job from XML:

ngen-j create <job-name> <xml-file> [--force]

Options:

  • --force - Skip confirmation when updating existing job

Delete a job:

ngen-j delete <job-name> [--force]

Options:

  • --force - Skip confirmation before deleting job

Note: Requires Jenkins permissions: Job/Create, Job/Update, Job/Configure, Job/Delete

Script Execution

If you have a bundled script, you can execute it directly:

ngen-j rancher --help
ngen-j rancher version

The CLI will look for scripts in the bundled scripts directory.

How It Works

  1. When you run ngen-j {command}, the CLI dispatcher checks in this order:
    • Built-in commands: Jenkins management commands
    • Scripts: Looks for a script at /usr/local/bin/ngen-j-{command} or bundled scripts
  2. If found, it executes the command with any additional arguments passed
  3. Scripts can be any executable file (bash, sh, Python, or binary)

Adding New Commands

Scripts

  1. Place a script in the ngen_j/scripts/ directory with name ngen-j-{your-command}
  2. Make sure it's executable: chmod +x ngen_j/scripts/ngen-j-{your-command}
  3. Use it with: ngen-j {your-command}

Development

Building the Package

python -m build

Publishing to PyPI

Menggunakan script otomatis:

./publish.sh --test      # Publish ke Test PyPI
./publish.sh --publish   # Publish ke PyPI production

Atau manual:

python -m build
python -m twine check dist/*
python -m twine upload dist/*

Untuk panduan lengkap, lihat PUBLISH.md.

Repository

License

MIT

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

ngen_j-0.1.3.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

ngen_j-0.1.3-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file ngen_j-0.1.3.tar.gz.

File metadata

  • Download URL: ngen_j-0.1.3.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for ngen_j-0.1.3.tar.gz
Algorithm Hash digest
SHA256 0dd8319baa8aeb8f8de25aa2dc2c2bc94570418c7a149c005faf3bd5f10f789c
MD5 c0738e1686ce671f306f2d2e56d67b6e
BLAKE2b-256 3986f51137138a46cc15d6c1781b5a451a3b8cf1dd8736c3eee8de01a36841e7

See more details on using hashes here.

File details

Details for the file ngen_j-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: ngen_j-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for ngen_j-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d6af8ebb1537278a0c545acba52e1d07a2717e2d569e18c1893e5b1af40bf74c
MD5 4394b4686355374ecaac86258f53bacd
BLAKE2b-256 a7c0ea0f4967267f380e925064a1b9dcb5e2c01a774c26bd3e14bf597876b321

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