Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to manage Jenkins with jcli

2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to use jcli to manage Jenkins". In daily operation, I believe many people have doubts about how to use jcli to manage Jenkins. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to manage Jenkins with jcli"! Next, please follow the editor to study!

As a developer, I usually use Jenkins as follows:

Find tasks related to my current job

Trigger task construction

Check the build log

Sometimes I may need to check the plug-in update center, install a new plug-in, or update an existing plug-in. Or, you want to upload a plug-in locally. In all of these cases, there is no need to access the UI interface or even the browser. I prefer to use the command line (CLI) to do most of the work. For example, I can use kubectl to manage my Kubernets cluster and create or modify Kubernetes resources. So I started thinking, "Why not use the command line to manage Jenkins?"

What is to create new wheels?

First of all, I've almost forgotten the command line that already exists, Jenkins CLI written in Java. Let me first show you how to use this command line.

Visit the page http://localhost:8080/jenkins/cli/ of Jenkins. You will see a command line similar to java-jar jenkins-cli.jar-s http://localhost:8080/jenkins/ help. Therefore, you need to download a jar file. We can download it with the command wget http://localhost:8080/jenkins/jnlpJars/jenkins-cli.jar.

At this point, you should see that this is not a Linux-style CLI. Consider the following points:

Users must have a JRE environment. This is not convenient for non-Java developers.

The command line is tedious to use and requires a lot of characters to be entered. We need to type java-jar jenkins-cli.jar-s http://localhost:8080/jenkins/ each time as a prefix to the command.

You cannot use some popular package manager installations, such as brew or yum.

Of course, the Java version of the command line is more compatible with Jenkins. However, I expect it to be easier to use. So I decided to use Golang to write a new command line that could run on multiple platforms.

This is the story of creating jcli.

Characteristics

Jcli configuration files that are easy to maintain

Support for managing multiple Jenkins

Plug-in management (list, search, install, upload)

Task management (search, build, log)

Open Jenkins in a browser

Restart Jenkins

Support for connection agents

How do I get it?

You can clone jcli from jenkins-cli 's code repository. Currently, we support three mainstream operating system platforms: MacOS, Linux, and Windows.

MacOS

You can install jcli using brew.

Brew tap jenkins-zh/jclibrew install jcliLinux

It is also very easy to install under Linux. All you have to do is execute the following command:

Curl-L https://github.com/jenkins-zh/jenkins-cli/releases/latest/download/jcli-linux-amd64.tar.gz|tar xzvsudo mv jcli / usr/local/bin/Windows

You can click here to find the latest version. Then, download the tar file and copy the extracted jcli to the system directory.

How do I start?

This is very easy to use. After you have installed jcli, you can generate a configuration sample with the following command:

$jcli config generatecurrent: yourServerjenkins_servers:- name: yourServer url: http://localhost:8080/jenkins username: admin token: 111e3a2f0231198855dceaff96f20540a9 proxy: "" proxyAuth: "# Goto 'http://localhost:8080/jenkins/me/configure', then you can generate your token.

In most cases, you should only need to modify three fields, including url, username, and token. Okay, I'm sure you're ready. You can then check to see if the github plug-in is installed in your Jenkins with the following command:

Jcli plugin list-filter name=github

Finally, the command line tool is still in the early stages of development, and we welcome contributions of any kind!

At this point, the study on "how to use jcli to manage Jenkins" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report