Welcome to jxctl’s documentation!

https://img.shields.io/pypi/v/jxctl.svg?color=green&style=plastic:alt:PyPI https://img.shields.io/pypi/l/jxctl.svg?style=plastic:alt:PyPI-License https://img.shields.io/pypi/pyversions/jxctl.svg?style=plastic:alt:PyPI-PythonVersion

User Guide

Installation

Install the package (or add it to your requirements.txt file):

pip install jxctl

Configuration

Add new context

jxctl context set <CONTEXT_NAME> --url <Jenkins URL> --user <Username> --token <Password/Access Token>
jxctl context set <CONTEXT_NAME> --url <Jenkins URL> --user <Username> --token <Password/Access Token> --default

Context Info

jxctl context info

List context

jxctl context list
jxctl context list --all

Update context

jxctl context set <CONTEXT_NAME> --url <Jenkins URL>
jxctl context set <CONTEXT_NAME> --user <Username> --token <Password/Access Token>

Rename context

jxctl context rename <CONTEXT_FROM> <CONTEXT_TO>

Delete context

jxctl context delete <CONTEXT_NAME>

Usage

Version

jxctl version

Jobs List

jxctl get jobs --all -f table
jxctl get jobs -o maven -o freestyle --count -f json
jxctl get jobs --option pipeline -c

Folders List

jxctl get folders -f table
jxctl get folders -c

Plugins List

jxctl get pluings
jxctl get pluings -c

Nodes List

jxctl get nodes
jxctl get nodes -c -f table

Job

Job info
jxctl job <JOB NAME>
jxctl job <JOB NAME> --format table
Delete a job
jxctl job <JOB NAME> --delete
Trigger job build
jxctl job <JOB NAME> --build
jxctl job <JOB NAME> --build --params <JSON>
Build info
jxctl job <JOB NAME> --buildinfo <Build Number>
Abort a build
jxctl job <JOB NAME> --abort <Build Number>

Plugin

jxctl plugin <Plugin Name>

Node

Node info
jxctl node <NODE NAME>
jxctl node <NODE NAME> -f table
Make offline
jxctl node <NODE NAME> --make-offline
jxctl node <NODE NAME> --make-offline -m <MESSAGE>
Make online
jxctl node <NODE NAME> --make-online

Developer Documentation

https://img.shields.io/circleci/project/github/deepan10/jxctl/master.svg?style=plastic:alt:CircleCIbranch https://img.shields.io/sonar/http/sonarcloud.io/jxctl/coverage.svg?color=green&style=plastic:alt:SonarCoverage https://codecov.io/gh/deepan10/jxctl/branch/master/graph/badge.svg https://img.shields.io/librariesio/release/pypi/jxctl/0.0.6.svg?style=plastic:alt:Libraries.iodependencystatusforspecificrelease

ctxcore

ctxcore - Core module for context operation

class ctxcore.CtxCore

CtxCore class for context operation

delete_context(context_name)

Delete the context :param context_name: context name str

list_context(all=None, context_name=None)

List Jenkins context :param name: all bool :param context_name: context name str

load_context()

Load context file from ~/.jxctl/config :raise FileNotFoundError: raise file not found exception

rename_context(context_from, context_to)

Rename the context name :param context_from: old context name str :param context_to: new context name str

set_context(name, url=None, user=None, token=None, default=None)

Add/Edit Jenkins context

Parameters
  • name – context name str

  • url – jenkins url url

  • user – jenkins user str

  • token – jenkins password/token str

  • default – set as default bool

set_current_context(name)

Change the current context

Parameters

name – context name

validate_context()

Check jenkins user, token and url is not null in context

write_context_file()

Write changes to context config file

jxcore

jxcore - Core module to intract with Jenkins API

class jxcore.JxCore

JxCore class for Jenkins operations

abort_job(job_name, build_number)

Abort the job build :param job_name: job name str :param build_number: build number of the job `int

build_info(job_name, build_no, format_display='json')

Build Info :param job_name: job name str :param build_no: build number of the job int :param format_display: displat format by json is default format str

delete_job(job_name)

Delete a job from Jenkins :param job_name: job name str

fetch_job_type(search_value)

Find the key by give the value in DICT :param name: Value name search_value str :returns: Key of the given Value key str

get_plugin_info(plugin_name)

Get a plugin info :param plugin_name: plugin name str

info()

Display the Context Information

job_info(job_name, format_display='json')

Display needed Job info in a table :param job_name: Job name job_name str :param format_display: displat format by json is default format str

list_all_folders(format_display='json', count=False)

Display all folders in Jenkins Context :param format_display: displat format by json is default format str :param count: count flag bool

list_all_jobs(format_display='json', count=False)

Display all jobs in Jenkins Context in a table :param format_display: displat format by json is default format str :param count: count flag bool

list_all_plugins(format_display='json', count=False)

Display all plugins in Jenkins context as a table :param format_display: displat format by json is default format str :param count: count flag bool

list_jobs(option_list, format_display='json', count=False)

Display only the specified class jobs in a table :param name: Job class list option_list list :param format_display: displat format by json is default format str :param count: count flag bool

list_nodes(format_display='json')

Get list of nodes :param format_display: displat format by json is default format str

node_action(node_name, action, message=None)

Node operations like make offile and online :param node_name: node name str :param action: node operation (offline/online) str :param message: offline reason str

node_info(node_name, format_display='json')

Node info :param node_name: node name str :param format_display: displat format by json is default format str

trigger_job(job_name, params=None)

Build a Job :param job_name: job name str :param params: parameters for job dict

jxsupport

jxsupport support module jxctl

class jxsupport.JxSupport

JxSupport class for support opertions like display

print(source, format_display='json', count=False)

Print method to display result :param source: source dictionary dict :param format_display: displat format by json is default format str :param count: count flag bool

static print_json(source, count=False)

Display the dictionary in json format :param source: source dictionary dict :param count: count flag bool

static print_table(source, count=False)

Display the dictionary in table format :param source: source dictionary dict :param count: count flag bool

Commands References

jxctl

jxctl - jenkins command line tool

jxctl [OPTIONS] COMMAND [ARGS]...

context

Set and Get Jenkins context

jxctl context [OPTIONS] COMMAND [ARGS]...
delete

Delete a jenkins context

jxctl context delete [OPTIONS] CONTEXT_NAME

Arguments

CONTEXT_NAME

Required argument

info

Show the infomation about jenkins

jxctl context info [OPTIONS]
list

List available jenkins context

jxctl context list [OPTIONS] [CONTEXT_NAME]

Options

-a, --all

Arguments

CONTEXT_NAME

Optional argument

rename

Rename the jenkins context

jxctl context rename [OPTIONS] CONTEXT_FROM CONTEXT_TO

Arguments

CONTEXT_FROM

Required argument

CONTEXT_TO

Required argument

set

Set jenkins Context

jxctl context set [OPTIONS] CONTEXT_NAME

Options

--url <url>

URL of the Jenkins instance

--user <user>

Username of the Jenkins instance

--token, --password <token>

Access token / password of the username

--default

Set as current context

Arguments

CONTEXT_NAME

Required argument

set-current

Set the current jenkins context

jxctl context set-current [OPTIONS] CONTEXT_NAME

Arguments

CONTEXT_NAME

Required argument

get

Get the jenkins resources(jobs, plugin, nodes, etc.. ) from jenkins

jxctl get [OPTIONS] COMMAND [ARGS]...
folders

Get all folders from jenkins

jxctl get folders [OPTIONS]

Options

-f, --format <format>

Display format(json/table). Default=json

-c, --count

Returns the number of plugin installed

jobs

Get list of job from jenkins

jxctl get jobs [OPTIONS]

Options

-c, --count

Returns number of jobs

-a, --all

List all(maven,freestly, pipelinemulti-branch, matrix and org) jobs

-o, --option <option>

Possible Options pipeline, multi-branch, maven, freestyle, matrix, org

-f, --format <format>

Display format(json/table). Default=json

--help

Print help message

nodes

Get list of nodes from jenkins

jxctl get nodes [OPTIONS]

Options

-f, --format <format>
plugins

List all installed plugins from jenkins

jxctl get plugins [OPTIONS]

Options

-f, --format <format>

Display format(json/table). Default=json

-c, --count

Returns the number of plugin installed

job

Job info and operation

jxctl job [OPTIONS] JOB_NAME

Options

--build

Triggers the build

--params <params>

Trigger build with params in Key:Value pair

--abort <abort>

Abort the build

--buildinfo <buildinfo>

Get build info

-d, --delete

Delete a job

-f, --format <format>

Display format(json/table). Default=json

Arguments

JOB_NAME

Required argument

node

Get node info and operation

jxctl node [OPTIONS] NODE_NAME

Options

--make-offline
--make-online
-m, --message <message>

Offline reason

-f, --format <format>

Display format(json/table). Default=json

Arguments

NODE_NAME

Required argument

plugin

Get plugin information

jxctl plugin [OPTIONS] PLUGIN_NAME

Arguments

PLUGIN_NAME

Required argument

version

Show the version and info of jxctl

jxctl version [OPTIONS]

Indices and tables