jenkins-fire-cli
A Jenkins command line tool built with python-fire that wraps the jenkins-cli and job-dsl-core.
Prerequisite
You need to ensure Java and Python>=3.8 are in the PATH to use this tool.
Install
It can be installed by the following command.
pip install jenkins-fire-cli
Get Started
Provision
You need to set Jenkins site url and user credential for the first time
jenkins-fire-cli config set jenkins.url http://your-jenkins-site
jenkins-fire-cli config set user.name john.doe
# user.token is optional, but you will be asked to type it when it is missing
# either api token or user's password will be OK, but it's recommneded to use token for the sake of security
jenkins-fire-cli config set user.token passw0rd
Before you start to run Jenkins commands, don't forget to run the init command for the first time, which will download jenkins-cli.jar and job-dsl-core-standalone.jar automatically.
jenkins-fire-cli init
Run jenkins-cli commnads
As jenkins-fire-cli is a wrapper of jenkins-cli and job-dsl-core to make them easier to use,
you can find the document of jenkins-cli in your Jenkins site or run the following command to open in browser.
jenkins-fire-cli doc --open
You can use the run sub-command to execute jenkins-cli command, for example
jenkins-fire-cli run list-jobs
# It is equivalent to "java -jar jenkins-cli.jar -s http://localhost:9090/ -webSocket list-jobs"
# For command with multiple arguments you need to quote them with ""
jenkins-fire-cli run "get-job my-job"
Run job-dsl commands
You can also run the job-dsl command. For example you have a job-dsl script with the following content.
// file: /tmp/sample.dsl
pipelineJob('job-dsl-plugin') {
definition {
cpsScm {
scm {
git {
remote {
url('https://github.com/jenkinsci/job-dsl-plugin.git')
}
branch('*/master')
}
}
lightweight()
}
}
}
Then you can run the following command to generate the job XML configuration.
jenkins-fire-cli dsl /tmp/sample-dsl.groovy
Then you will find a file named job-dsl-plugin.xml is generated.
Now you can run anthor command to create this job in jenkins:
jenkins-file-cli run 'create-job job-dsl-plugin' < job-dsl-plugin.xml
Then you will find a new job named job-dsl-plugin has been created in jenkins.
Environment Variables
If you want to use this tool in CI system, you may use the following environment variable instead of global setting.
JENKINS_USER_ID: equivalent touser.nameJENKINS_API_TOKEN: equvalent touser.tokenJENKINS_URL: equvalent tojenkins.urlJENKINS_JOB_DSL_PATH: path to the job-dsl jar package, you may skipinitwhen this is setJNEKINS_CLI_PATH: path to the jenkins-cli jar package, you may skipinitwhen this is set
Metadata
Release files for jenkins-fire-cli 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jenkins-fire-cli-0.1.1.tar.gz | 16.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jenkins_fire_cli-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.8 kB
Release files / jenkins-fire-cli-0.1.1.tar.gz
| Download URL | jenkins-fire-cli-0.1.1.tar.gz |
|---|---|
| Size | 16.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0baa80d4afcd5a753619a07c9f5a6639f56ca347056fda3daedbb6982f506dcb
|
|
BLAKE2b-256 checksum How to use checksums |
f9fdae9d3ed1797b0316dc5c158f020f6dd18e0136fa634f29ffe247e78ccc86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.12
|
Release files / jenkins_fire_cli-0.1.1-py3-none-any.whl
| Download URL | jenkins_fire_cli-0.1.1-py3-none-any.whl |
|---|---|
| Size | 17.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
961eb07b814dd749d735cab134aa1f5cdb76d7adcae20887c164250b5abff454
|
|
BLAKE2b-256 checksum How to use checksums |
1767f225db8972e6f443e56c6d4193447232ae524adc1c38d0fcdbac7d904ef7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.12
|