Skip to main content

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

Release files for ngen-j 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ngen-j 0.1.3
File Size Uploaded
ngen_j-0.1.3.tar.gz 15.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ngen-j 0.1.3
File Interpreter ABI Platform
ngen_j-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 29.9 kB

Release files / ngen_j-0.1.3.tar.gz

Download URL ngen_j-0.1.3.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0dd8319baa8aeb8f8de25aa2dc2c2bc94570418c7a149c005faf3bd5f10f789c
BLAKE2b-256 checksum
How to use checksums
3986f51137138a46cc15d6c1781b5a451a3b8cf1dd8736c3eee8de01a36841e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / ngen_j-0.1.3-py3-none-any.whl

Download URL ngen_j-0.1.3-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d6af8ebb1537278a0c545acba52e1d07a2717e2d569e18c1893e5b1af40bf74c
BLAKE2b-256 checksum
How to use checksums
a7c0ea0f4967267f380e925064a1b9dcb5e2c01a774c26bd3e14bf597876b321
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page