Jenkins 学习笔记

一、安装部署

  • 1、Jenkins 在开发过程中所属位置

  • 2、Jenkins + Maven + Git 持续集成基础使用

  • 3、安装硬件环境和知识储备

一、准备三台服务器

* Jenkins 主服务器  Jenkins 测试服务器 GitLab 代码托管服务器 

二、GitLab 安装

  • 1、GitLab 介绍及安装准备
  • 2、SSH 下安装
  • 3、 Docker 下安装

GitLab 常用命令

gitlab-ctl start                  # 启动所有 gitlab 组件;
gitlab-ctl stop                   # 停止所有 gitlab 组件;
gitlab-ctl restart                # 重启所有 gitlab 组件;
gitlab-ctl status                 # 查看服务状态;
gitlab-ctl reconfigure            # 启动服务;
vi /etc/gitlab/gitlab.rb          # 修改默认的配置文件;
gitlab-ctl tail                   # 查看日志;

1、SSH 安装

官方文档:GitLab最新版下载安装_GitLab中文免费版-极狐GitLab中文官方网站

2、Docker 安装

1、安装Docker:CentOS8 安装 Docker repo ‘appstream‘ 下载元数据失败_仍怀热爱的博客-CSDN博客

2、 安装GitLab 至少 6G 内存

docker run --detach \
  --hostname 192.168.1.8 \
  --publish 443:443 --publish 80:80 \
  --name gitlab \
  --restart always \
  --volume $GITLAB_HOME/config:/etc/gitlab:Z \
  --volume $GITLAB_HOME/logs:/var/log/gitlab:Z \
  --volume $GITLAB_HOME/data:/var/opt/gitlab:Z \
  --shm-size 256m \
  registry.gitlab.cn/omnibus/gitlab-jh:latest

 3、进入 GitLab 容器

docker exec -it  gitlab /bin/bash

4、访问 GitLab 服务器地址 192.168.1.8

当首次运行出现502错误的时候排查两个原因

  1. 虚拟机内存至少需要4g
  2. 稍微再等等刷新一下可能就好了

5、管理员账号登录

用户名:root

密码存在下面文件中,登录后需要改密码不然24小时之后会失效

cat /etc/gitlab/initial_root_password

密码是 Password 后面的字符串

root@192:/# cat /etc/gitlab/initial_root_password 
# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: JLDZaPOGsPVONhL7BBZ4mgrcO6GxJuHlfReZGldE4qQ=

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.

6、提交一份代码到GitLab

  三、Jenkins 安装

Jenkins 官方文档:Jenkins

 1、安装 Jenkins

docker pull jenkins/jenkins:latest

2、创建 Jenkins 目录

mkdir -p /root/docker/jenkins

3、安装启动 Jenkins

docker run -d \
  -u root \
  --name jenkins \
  -p 9302:8080 \
  -v /root/docker/jenkins:/var/jenkins_home \
  -v /var/run/docker.sock:/var/run/docker.sock \
  jenkins/jenkins

4、查看 Jenkins 容器ID && 进入容器

docker ps
docker exec -u 0 -it 容器ID /bin/bash

5、查看 Jenkins 解锁密码

[root@localhost ~]#  cat /root/docker/jenkins/secrets/initialAdminPassword
5661515b79f24386a039659438c8c008

6、安装 Jenkins 插件 

 7、安装完成

二、安装jdk、maven、git

三、安装 jenkins 插件

 四、添加任务

 1、创建一个 jenkins 任务

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值