基于Jenkins+gitlab+tomcat,自动部署项目。
主机 | 服务 |
---|
192.168.75.121 | gitlab | 192.168.75.122 | Jenkins | 192.168.75.123 | tomcat |
1. 部署gitlab:
yum install https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-14.0.0-ce.0.el7.x86_64.rpm -y
# 修改配置文件:
vim /etc/gitlab/gitlab.rb
...
# 设置域名或者访问IP:
external_url 'http://192.168.75.121'
...
# 重载配置:
gitlab-ctl reconfigure
1.1 设置gitlab的初始密码:
直接访问75.121,用户名是root,密码在临时文件中可以找到:
[root@node1 ~]# 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: z0w+KobRfyK2awrsfUV9RT312gKEiVFMSsoiQamYFRM=
修改初始密码:
[root@node1 ~]# gitlab-rake "gitlab:password:reset[root]"
Enter password:
1.2 创建组:
通常公司会有很多开发组,每个开发组负责不同的的项目。
1.3 创建项目:
1.4 创建用户:
现在只有管理员,可以创建普通用户,并分配到指定组来管理特定项目。
设置密码:
1.5 分配组:
用户权限:http://192.168.75.121/help/user/permissions
1.6 切换普通用户登录:
1.7 模拟上传项目代码到gitlab:
[root@node1 ~]# mkdir -p /data/objects/jpress
[root@node1 ~]# cd /data/objects/jpress
[root@node1 jpress]# wget -c https://github.com/JPressProjects/jpress/archive/refs/tags/v4.1.4.tar.gz
[root@node1 jpress]# tar xf v4.1.4.tar.gz
[root@node1 jpress]# mv jpress-4.1.4/* .
[root@node1 jpress]# rm -rf v4.1.4.tar.gz jpress-4.1.4/
[root@node1 jpress]# ls
changes.txt Dockerfile jpress-service module-article starter-tomcat
codegen install.sh jpress-service-provider module-page upgrade.sh
doc jpress-addons jpress.sql module-product
docker jpress-commons jpress-template pom.xml
docker-build.sh jpress-core jpress-web README.md
docker-compose.yml jpress-model LICENSE starter
# git初始化:
[root@node1 jpress]# git init
[root@node1 jpress]# git remote add origin http://192.168.75.121/dev1_group/jpress.git
[root@node1 jpress]# git add .
[root@node1 jpress]# git commit -m "add jpress"
[root@node1 jpress]# git push -u origin master
# 输入xiaoming用户:
Username for 'http://192.168.75.121': xiaoming
# 输入xiaoming密码:
Password for 'http://xiaoming@192.168.75.121':
Counting objects: 1899, done.
Compressing objects: 100% (1620/1620), done.
...
查看gitlab端项目:
到此gitlab的准备就完成了,下面讲进行Jenkins的安装,配置。
欢迎点赞,收藏,你的喜欢就是我原创的动力,Jenkins系列将会持续更新。
|