gitlab deployment use, jenkins deployment use

Install online

gitlab

download gitlab

https://docs.gitlab.com/ee/update/package/#upgrade-using-the-official-repositories
https://packages.gitlab.com/gitlab/gitlab-ce?_gl=11rafpow_gaMjcwMDkzMDU4LjE2NzcyOTM4MzQ._ga_ENFH3X7M5Y*MTY3NzQwMzEzMi4zLjEuMTY3NzQwMzI0Ny4wLjAuMA…
insert image description here
insert image description here

install gitlab

Install jdk, version 1.8 or above

yum -y install java-1.8.0-openjdk.x86_64

Install the gitlab rpm package

yum -y install gitlab-ce-15.9.1-ce.0.el7.x86_64.rpm

Configure gitlab access address

#配置域名,需要有相应的DNS解析
#ip为git喇叭服务器自身IP地址
vim /etc/gitlab/gitlab.rb
external_url 'http://ip'
external_url 'http://ip'

load configuration

gitlab-ctl reconfigure

View gitlab status

[root@gitlab ~]# systemctl status gitlab-runsvdir.service
● gitlab-runsvdir.service - GitLab Runit supervision process
   Loaded: loaded (/usr/lib/systemd/system/gitlab-runsvdir.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2023-02-26 11:16:33 CST; 6h ago
 Main PID: 11742 (runsvdir)

use gitlab

View gitlab administrator password
administrator root

less /etc/gitlab/initial_root_password

Log in to gitlab
curl http://ip

Set Chinese

insert image description here
insert image description here

Change administrator password

insert image description here

insert image description here

create group, create project, create user

insert image description here
insert image description here

jenkins

download jenkins

Jenkins URL
https://www.jenkins.io/
https://www.jenkins.io/download/
https://get.jenkins.io/war-stable/
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

install jenkins

Install jdk, version 1.8 or above

yum -y install java-1.8.0-openjdk.x86_64

Configure working directory

#不做配置默认目录为	/root/.jenkins/
vim /etc/profile
export JENKINS_HOME=/data/CICD

Load environment variables

source /etc/profile

Start jenkins, the log path is customized according to the situation

nohup java -jar jenkins.war > /root/jenkins.log 2>&1 &
  • or write a script to start
vim jenkins-start.sh
#!/bin/bash

date=$(date +'%Y-%m-%d')
nohup java -jar jenkins.war > /root/jenkins-${date}.log 2>&1 &

use jenkins

Log view administrator password
less /root/jenkins-2023-02-26.log

insert image description here
Log in to jenkins
http://ip:8080
administrator admin
plug-in select recommended online installation
view plug-in
insert image description here
insert image description here
insert image description here

change admin password

insert image description here

insert image description here
Save changes, log in again
insert image description here

Configure pull code

Configure the account password for logging in to gitlab to pull the code

insert image description here
insert image description here
insert image description here
Select the account password here, fill in the gitlab administrator account password, saveinsert image description here

configuration items

insert image description here
insert image description here

Configure the gitlab warehouse

View the address of the gitlab warehouse
insert image description here
Select git, configure the address of the warehouse, select the certificate insert image description here
and select the branch
insert image description here

configure build

Configure build scripts, mvn, npm, etc.
insert image description here
Use GitLab webhook
to install the gitlab plug-in to use GitLab webhook,
realize gitlab push code, jenkins automatically builds
jenkins configuration
insert image description here
insert image description here
insert image description here
insert image description here
gitlab configuration
Enter the project to be configured, fill in the url and token on jenkins
insert image description here

Construct

insert image description here

build success

insert image description here

insert image description here

Install offline

#上传jenkins的war包到服务器
#启动jenkins,如不做jenkins家目录变更,执行
#操作已在线安装jenkins的服务器
cd /root/.jenkins/
tar -zcf plugin.tar.gz plugin




#操作离线要安装jenkins的服务器
#上传在线安装时已下载的Jenkins插件到服务器到的jenkins插件目录
tar -xf  plugin.tar.gz -C /root/.jenkins/
#重启jenkins

Error reporting when installing jenkins offline

1. Unable to enter jenkins

error phenomenon

After entering the initial password for offline installation, the card is stuck on the page where offline installation is detected. The page displays two options, configure proxy and skip plug-in installation

After clicking to skip the plug-in installation, a 403 error is reported and the jinkens cannot be entered

Solve the error

The reason is that jenkins has been installed on the server before

delete old jenkins files

find / -iname jenkins | xargs -n 1000 rm -rf 

restart jenkins

2. Unable to create credential

error phenomenon

Jenkins is installed offline. After entering jenkins, an error 403 is reported when creating a credential

HTTP ERROR 403 No valid crumb was included in the request
....
....
....
Powered by Jetty://9.4.33......

Solve the error

Solution reference:
https://www.cnblogs.com/guohong-hu/p/14519220.html

The reason is that the CSRF security verification problem of the new version of Jenkins leads to

Modify the configuration file

I modified the jenkins home directory during installation, so the configuration file location is `/data/CICD/config.xm

vim config.xml
  <crumbIssuer class="hudson.security.csrf.DefaultCrumbIssuer">
    <excludeClientIPFromCrumb>false</excludeClientIPFromCrumb>
  </crumbIssuer>

Modify false to true

  <crumbIssuer class="hudson.security.csrf.DefaultCrumbIssuer">
    <excludeClientIPFromCrumb>true</excludeClientIPFromCrumb>
  </crumbIssuer>

restart jenkins

Guess you like

Origin blog.csdn.net/qq_44659804/article/details/129228195