Use Jenkins update server

Jenkins used in two ways

Simplify, from the initial understanding of Jenkins', to use Jenkins landed, found there will be two kinds of ideas:

  • 重 Jenkins, Jenkins control the entire update process. such as:

    • Pulling code, compiled
    • Production docker image, upload warehouse
    • Remote mirroring open Docker containers, etc.

    Heavy Jenkins, will inevitably lead to specific projects done in accordance with Jenkins docking specification, increase the number of additional workload

  • 轻 Jenkins , Jenkins only as a layout controller does not participate update details

    • Jenkins is responsible Around: control panel, update history, mail notification, automatic triggering and more
    • Project update provided by the server script
    • The project parties need to know Jenkins. Jenkins project no party can also perform a manual update server script

This article describes 轻 JenkinsJenkins update server method

Jenkins notes under the first deployment environment, and finally how 轻 Jenkins

Installation Jenkins

The official document:

Centos7 installation script is as follows:

#!/bin/bash
set -ex
yum install -y java-1.8.0-openjdk
wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum install -y jenkins
systemctl enable jenkins
systemctl restart jenkins

First Run

The official document: https://jenkins.io/doc/book/installing/#unlocking-jenkins

The article mentions the following things:

  1. It will be prompted to enter the token.
    View token as follows:
    sudo cat /var/lib/jenkins/secrets/initialAdminPassword
    
  2. You will be prompted to install the plugin. Click Custom installation, ssh relevant search plug-in and hook on
  3. You will be prompted to create an administrator account. We can create the next
  4. (Optional) Chinese plug-in installation, installation of Localization: Chinese (Simplified)plug-ins

Set up凭证

Jenkins 凭证means that all kinds of password, such as:

  • GIT account password
  • SVN account password
  • SSH account password
  • SSH private key account etc.

The official document: https://jenkins.io/doc/book/using/using-credentials/

Figure exemplified below:

1, a left click on the main interface 凭证:Here Insert Picture Description

2, a click on the left main interface 凭证-系统:Here Insert Picture Description

Figure 3, click 全局凭据 (unrestricted)- 添加凭证: Here Insert Picture Description
Fill out information, you can add the next

Set SSH remote hosts

Jenkins disposed remote manipulation更新机

Click on the main interface 系统管理-系统设置

Setting example:
Here Insert Picture Description

After setting, Jenkins method has completed 90% of the

The last update took the script to specific projects

轻 Jenkins principle

Jenkins 项目`更新服` 项目`目标服务器` ssh 远程调用更新脚本 执行更新脚本 部署、更新服务器 ssh 远程更新目标服务器 部署、更新服务器 alt [ 本地部署、更新 ] Jenkins 项目`更新服` 项目`目标服务器`

Timing diagram analysis:

  • Jenkins just need to know:
    • Linux SSH account凭证
    • Linux SSH remote hosts
    • Script commands to be executed
  • specific project
    • According to their own circumstances, to deploy a variety of ways:
      • Can Docker
      • Can K8S
      • Be an executable file, and so on
    • Direct local deployment, update
    • Project update service can manipulate project aims clothes, etc.

The last presentation, Jenkins was how SSH script execution project update service

New Task

Directly on the map Description

1, a click on the left of the main screen 新建任务, FIG fill information, click OK.Here Insert Picture Description

2, fill in the 构建information, point 保存toHere Insert Picture Description

the above

Published 129 original articles · won praise 73 · views 160 000 +

Guess you like

Origin blog.csdn.net/u013272009/article/details/87810495