CI/CD 是指持续集成(Continuous Integration)和持续部署(Continuous Deployment)或持续交付(Continuous Delivery)
持续集成(Continuous Integration)
持续集成是一种软件开发实践,团队成员频繁地将他们的工作集成到共享的代码仓库中。其主要特点包括:
持续部署(Continuous Deployment)
持续部署是在持续集成的基础上,将通过所有测试的代码自动部署到生产环境中。其特点如下:
持续交付(Continuous Delivery)
持续交付与持续部署类似,但不一定自动部署到生产环境,而是随时可以部署。其重点在于确保软件随时处于可发布状态。
CI/CD 的好处包括:
#下载
[root@gitlab ~]# dnf install git -y
# 初始化
[root@gitlab luo]# git init
# 查看
[root@gitlab luo]# ls -a
. .. .git
建立用户信息
[root@gitlab luo]# git config --global user.name "luo"
[root@gitlab luo]# git config --global user.email "luo@timingluo.org"
未提交状态

提交后状态

追加内容,右M,在工作区被修改,但没提交
[root@gitlab luo]# echo >> README.md

提交后左绿,提交到暂存区
[root@gitlab luo]# git add README.md

提交到工作区
[root@gitlab luo]# git commit -m "README.md v2"

git status -s 无任何显示,标识已经提交到版本库
当再次修改
[root@gitlab luo]# vim README.md

右红M表示文件在工作区被修改

撤销修改
[root@gitlab luo]# git checkout -- README.md
[root@gitlab luo]# cat README.md
luo

重新修改
[root@gitlab luo]# echo luoluo > README.md
[root@gitlab luo]# git add README.md
[root@gitlab luo]# git status -s
M README.md

从暂存区撤销
[root@gitlab luo]# git restore --staged README.md
[root@gitlab luo]# git status -s
M README.md

重新提交
[root@gitlab luo]# git add README.md
[root@gitlab luo]# git status -s
M README.md

更新
[root@gitlab luo]# git commit -m "update v1"
[master f126628] update v1
1 file changed, 1 insertion(+), 2 deletions(-)
[root@gitlab luo]# git status -s

更新文件
[root@gitlab luo]# echo luo1 >> README.md
[root@gitlab luo]# git add README.md
[root@gitlab luo]# echo luo1 >> README.md
[root@gitlab luo]# git status -s
MM README.md

MM表示有一部分在暂存区,还有一部分没有提交
如果现在提交只能提交在暂存区中的部分
[root@gitlab luo]# git commit -m "update v2"
[master c155d30] update v2
1 file changed, 1 insertion(+)
[root@gitlab luo]# git status -s
M README.md

查看已暂存和未暂存的修改变化
[root@gitlab luo]# echo luo >> README.md
[root@gitlab luo]# git diff
diff --git a/README.md b/README.md
index a700f83..6240833 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,4 @@
luoluo
luo1
+luo1
+luo

跳过使用暂存区,只能在提交过的在版本库中存在的文件使用如果文件状态是“??”不能用此方法
撤销工作区中删除动作
[root@gitlab luo]# touch luo.txt
[root@gitlab luo]# git add luo.txt
[root@gitlab luo]# git commit -m "add luo.txt"
[master aa037c1] add luo.txt
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 luo.txt
[root@gitlab luo]# rm -rf luo.txt
[root@gitlab luo]# git status -s
D luo.txt
右D 表示文件在工作区被删除

[root@gitlab luo]# mkdir dir1
[root@gitlab luo]# touch dir1/.file2
[root@gitlab luo]# git status -s
?? dir1/

部署gitlab
# 在安装包之前需配置好软件仓库来解决依赖性
[root@gitlab luo]# yum install -y curl policycoreutils-python-utils openssh-server perl

修改配置文件
[root@gitlab luo]# cd /etc/gitlab/
[root@gitlab gitlab]# vim gitlab.rb
[root@gitlab gitlab]# gitlab-ctl reconfigure

使用gitlab-crt生效配置
[root@gitlab gitlab]# gitlab-ctl reconfigure
查看原始密码
[root@gitlab gitlab]# cat /etc/gitlab/initial_root_password
登录

更改密码




生成sshd密钥
[root@gitlab gitlab]# ssh-keygen
[root@gitlab ~]# cat .ssh/id_rsa.pub

上传公钥到gitlab中


下载项目


[root@jenkins-node1 ~]# ls
公共 图片 音乐 jenkins-2.462.2-1.1.noarch.rpm
模板 文档 桌面 plugins.tar.gz
视频 下载 anaconda-ks.cfg
[root@jenkins-node1 ~]# dnf install jenkins-2.476-1.1.noarch.rpm
[root@jenkins-node1 ~]# systemctl enable --now jenkins.service
Created symlink /etc/systemd/system/multi-user.target.wants/jenkins.service → /usr/lib/systemd/system/jenkins.service.
[root@jenkins-node1 ~]# cat /var/lib/jenkins/secrets/initialAdminPas

使用下载好的插件
[root@jenkins-node1 jenkins]# rm -rf /var/lib/jenkins/*
[root@jenkins-node1 jenkins]# cd
[root@jenkins-node1 ~]# tar zxf plugins.tar.gz -C /var/lib/jenkins/
[root@jenkins-node1 ~]# cd /var/lib/jenkins/
[root@jenkins-node1 jenkins]# ls
plugins
[root@jenkins-node1 jenkins]# systemctl restart jenkins.service






设置密码



添加密钥





关闭远程登录需要的yes/no
[root@jenkins-node1 ~]# vim /etc/ssh/ssh_config

更该类型

设置计划任务

设置查看有没有建立成功

点击立刻创建

查看
