Home

Awesome

<div align="center"> <img src="icon.png" width=200 height=200> <h1>JnsCLI</h1> </div> JnsCLI is a command-line interface for Jenkins, the popular CI/CD automation server. This tool allows you to interact with your Jenkins server directly from the command line, making it easier to manage jobs, builds, and server configurations without the need for the web interface. It also supports AI-powered error analysis to help you quickly identify and fix build errors.

Table of Contents

Quick Start (Installation from Binary)

Download the binary for your platform:

# for x86-64
wget -O jns-0.1.1-amd64 https://github.com/mirum8/jnscli/releases/download/v0.1.1/jns-0.1.1-amd64 \
&& chmod +x jns-0.1.1-amd64 && mkdir -p $HOME/.local/bin/ \
&& mv jns-0.1.1-amd64 $HOME/.local/bin/jns

# for ARM (Apple M1)
wget -O jns-0.1.1-arm64 https://github.com/mirum8/jnscli/releases/download/v0.1.1/jns-0.1.1-arm64 \
&& chmod +x jns-0.1.1-arm64 && mkdir -p $HOME/.local/bin/ \
&& mv jns-0.1.1-arm64 $HOME/.local/bin/jns

Add the binary to your PATH:

# for bash
echo "export PATH=\$PATH:$HOME/.local/bin/" >> $HOME/.bashrc && source $HOME/.bashrc
# for zsh
echo "export PATH=\$PATH:$HOME/.local/bin/" >> $HOME/.zshrc && source $HOME/.zshrc

Connect to your Jenkins server. You will be prompted to enter the server URL, username, and token:

jns connect

List Jenkins jobs:

jns list

Run a job:

jns build <jobName>

Manual Compilation

Prerequisites

Steps

git clone https://github.com/mirum8/jnscli.git \
&& cd jnscli \
&& ./mvnw clean native:compile -Pnative \
&& mkdir -p $HOME/.local/bin/ \
&& mv target/jns $HOME/.local/bin/jns

Add the binary to your PATH:

# for bash
echo "export PATH=\$PATH:$HOME/.local/bin/" >> $HOME/.bashrc && source $HOME/.bashrc
# for zsh
echo "export PATH=\$PATH:$HOME/.local/bin/" >> $HOME/.zshrc && source $HOME/.zshrc

Features

Usage

Start the CLI application and use the available commands to interact with your Jenkins server.

Commands

List Jenkins Jobs

List all jobs on the Jenkins server:

jns list

List jobs

List jobs in a specific folder:

jns list <folder>

Run a Job

Run a job on the Jenkins server:

jns build <jobId|jobName> [-p, --params <key=value>...] [-q, --quiet] [-l, --log] [--ai]

Build job

You can also use an ID number (prefixed by '%') from the 'list' output to start a job:

Build job by ID

If the job already started, you can abort the previous build and start a new one (or cancel the new build):

Abort and build

Options:

Abort

Abort a running job:

jns abort <jobId> [--b, --buildNumber]

Connect

Connect to the Jenkins server:

jns connect

Alias

Manage job aliases:

jns alias add <aliasName> <jobIdOrUrl> # Add an alias
jns alias rm <aliasName> # Remove an alias
jns alias ls # List all aliases

Info

Get information about a job:

jns info <jobId> [options]

Options:

Error

Get error information for the last or a specific build:

jns error <jobId> [Options]

Options:

If parameters are not specified, the command will return the error information for the last failed build within the last 5 builds.

AI Commands

AI-powered error analysis is available for Jenkins builds. To use this feature, you need to configure the AI settings ( Ollama and OpenAI are supported as AI services):

jns ai configure

After configuring the AI settings, you can test the AI service availability:

jns ai test

Now you can use --ai parameter in the 'build' and 'error' commands to analyze build errors with AI.

Analyze error with AI

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.