### Start Jenkins with Custom Settings Source: https://context7.com/jenkins-zh/jenkins-cli/llms.txt Demonstrates how to start a Jenkins instance using the jcli command with custom port, version, setup wizard, Docker image, and environment variables. ```bash jcli center start \ --port 8080 \ --version 2.346.3 \ --setup-wizard=false \ --image jenkins/jenkins:lts \ --env JAVA_OPTS="-Xmx2048m" ``` -------------------------------- ### Download jcli using Docker (Linux) Source: https://github.com/jenkins-zh/jenkins-cli/blob/master/docs/book/en/download.md This example shows how to create a Docker container from the jenkinszh/jcli image, copy the jcli binary to the host system, and then remove the container. Requires Docker to be installed and running. ```shell jcli_id=$(docker create jenkinszh/jcli) && sudo docker cp $jcli_id:/usr/local/bin/jcli /usr/local/bin/jcli && docker rm -v $jcli_id ``` -------------------------------- ### Install Development Tools Source: https://github.com/jenkins-zh/jenkins-cli/blob/master/CONTRIBUTING.md Executes the `make tools` command to install necessary development tools for the project. This command ensures that all required dependencies for development are available. ```bash make tools ``` -------------------------------- ### Install Jenkins CLI Plugins Source: https://github.com/jenkins-zh/jenkins-cli/blob/master/README.md Demonstrates how to fetch available plugins and install a specific plugin (e.g., 'account') for the Jenkins CLI tool. This extends the functionality of jcli. ```text jcli config plugin fetch jcli config plugin install account ``` -------------------------------- ### Manage Jenkins Plugins with Go Client Source: https://context7.com/jenkins-zh/jenkins-cli/llms.txt This Go code snippet demonstrates how to manage Jenkins plugins using the Jenkins CLI Go client library. It covers retrieving installed plugins and installing new ones. Ensure you have the Jenkins CLI Go client library installed. ```go // Plugin management via Go client package main import ( "fmt" "github.com/jenkins-zh/jenkins-cli/client" ) func main() { pluginMgr := &client.PluginManager{ JenkinsCore: client.JenkinsCore{ URL: "http://localhost:8080", UserName: "admin", Token: "your-token", }, UseMirror: true, ShowProgress: true, MirrorURL: "https://mirrors.tuna.tsinghua.edu.cn/jenkins/", } // Get installed plugins plugins, err := pluginMgr.GetPlugins(1) if err != nil { panic(err) } for _, plugin := range plugins.Plugins { fmt.Printf("%s v%s (Update: %v)\n", plugin.ShortName, plugin.Version, plugin.HasUpdate) } // Install plugins err = pluginMgr.InstallPlugin([]string{"git", "pipeline-model-definition"}) if err != nil { panic(err) } } ``` -------------------------------- ### Download jcli Development Version (macOS) Source: https://github.com/jenkins-zh/jenkins-cli/blob/master/docs/book/en/download.md This example demonstrates how to download the development version of jcli for macOS using a Docker container. It requires Docker to be installed and running. ```shell jcli_id=$(docker create jenkinszh/jcli:dev) && sudo docker cp $jcli_id:/bin/darwin/jcli . && docker rm -v $jcli_id ``` -------------------------------- ### Build Jenkins Job with Parameters Source: https://github.com/jenkins-zh/jenkins-cli/blob/master/client/doc/README.md An example function demonstrating how to trigger a Jenkins job with specific parameters using the `jenkins-cli` client. It shows how to define and pass parameter values for 'BRANCH_TAG', 'ENV', and 'DEPLOY_TYPE' when building a job. ```Go type JobBuildOptions struct { Env string JobName string BranchTag string } func BuildJob(jobBuild JobBuildOptions) (e error) { core, e := GetJenkinsCore() jobClient = client.JobClient{core} if e != nil { return } param1 := client.ParameterDefinition{ Description: "pre and prd please use tag", Name: "BRANCH_TAG", Type: "Branch or Tag", Value: jobBuild.BranchTag, DefaultParameterValue: client.DefaultParameterValue{Value: "origin/master"}, } param2 := client.ParameterDefinition{ Description: "choice", Name: "ENV", Type: "Choice Parameter", Value: jobBuild.Env, DefaultParameterValue: client.DefaultParameterValue{Value: "qa"}, } param3 := client.ParameterDefinition{ Description: "Deploy Type", Name: "DEPLOY_TYPE", Type: "Choice Parameter", Value: "publish", DefaultParameterValue: client.DefaultParameterValue{Value: "publish"}, } params := []client.ParameterDefinition{param1, param2, param3} e = jobClient.BuildWithParams(jobBuild.JobName, params) return } ``` -------------------------------- ### Install Jenkins CLI on Windows using Scoop Source: https://github.com/jenkins-zh/jenkins-cli/blob/master/README.md Installs the Jenkins CLI tool on Windows using the Scoop package manager. Scoop is a command-line installer for Windows applications. ```text scoop install jcli ``` -------------------------------- ### Install jcli via APT Package Manager (Debian/Ubuntu) Source: https://github.com/jenkins-zh/jenkins-cli/blob/master/docs/book/en/download.md This snippet demonstrates how to add the Jenkins CLI APT repository for Debian-based systems and install jcli. It requires sudo privileges and apt-get. ```shell echo "deb [trusted=yes] https://dl.bintray.com/jenkins-zh/deb wheezy main" | sudo tee -a /etc/apt/sources.list sudo apt update ``` -------------------------------- ### Install jcli via YUM Package Manager Source: https://github.com/jenkins-zh/jenkins-cli/blob/master/docs/book/en/download.md This section details how to add the Jenkins CLI YUM repository and install jcli. It involves creating a repository configuration file and then using yum to install the package. Requires sudo privileges. ```shell cat > bintray-jenkins-zh-rpm.repo < /etc/bash_completion.d/jcli # Generate zsh completion jcli completion zsh > "${fpath[1]}/_jcli" # Generate fish completion jcli completion fish > ~/.config/fish/completions/jcli.fish # Generate PowerShell completion jcli completion powershell > jcli.ps1 ``` -------------------------------- ### Jenkins User API Operations Source: https://github.com/jenkins-zh/jenkins-cli/blob/master/client/doc/README.md Defines the API for managing users within Jenkins. It includes functions for creating a new user with specified username and password, and for deleting an existing user by their username. These operations are handled by the `UserClient`. ```Go // Create will create a user in Jenkins func (q *UserClient) Create(username, password string) (user *UserForCreate, err error) {...} // Delete will remove a user from Jenkins func (q *UserClient) Delete(username string) (err error) {...} ``` -------------------------------- ### Configure External Data URLs for jcli Source: https://context7.com/jenkins-zh/jenkins-cli/llms.txt This YAML configuration snippet shows how to define external data URLs for Jenkins instances within the jcli configuration. This allows 'jcli open' to access custom URLs like Grafana or SonarQube associated with a Jenkins server. ```yaml # Config with external data URLs jenkins_servers: - name: production url: https://jenkins.prod.example.com username: admin token: token-here data: grafana: https://grafana.prod.example.com sonar: https://sonarqube.prod.example.com ``` -------------------------------- ### Configure jcli Proxy Settings Source: https://github.com/jenkins-zh/jenkins-cli/blob/master/docs/book/en/proxy.md This snippet demonstrates how to add proxy configuration to the jcli configuration file. Users can edit the configuration using `jcli config edit` and add 'proxy' and 'proxyAuth' fields to their jenkins_servers entries. This is essential for connecting to Jenkins instances located behind a firewall. ```yaml jenkins_servers: - name: dev url: http://192.168.1.10 username: admin token: 11132c9ae4b20edbe56ac3e09cb5a3c8c2 proxy: http://192.168.10.10:47586 proxyAuth: username:password ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.