Jenkins入门(一)Jenkins介绍、GitLab基础环境安装

视频学习地址:01-Jenkins教程简介_哔哩哔哩_bilibili

一、介绍:

Jenkins是一个独立的开源自动化服务器,可用于自动化各种任务,如构建,测试和部署软件。

它替代了管理员手动集成、构建、测试,提交代码后自动接管,拉取、集成、构建、测试,大大减少了人力成本。 

二、安装环境准备 

1. GitLab的安装

(1)准备一台虚拟机,并且内存要大于5G(如果安装的带图形化可能需要更大的内存,这里我用的是Centos7图形化界面)。

(2)使用 命令: free -m 测试内存是否符合要求

[root@centos7 ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           5788         689        5520          28         579        4842
Swap:          2047           0        2047

(3)执行 ssh命令安装依赖

sudo yum install -y curl policycoreutils-python openssh-server perl
sudo systemctl enable sshd
sudo systemctl start sshd

(4)配置镜像

curl -fsSL https://packages.gitlab.cn/repository/raw/scripts/setup.sh | /bin/bash

(5) 开始安装

       注: 这里的ip地址是自己本机的ip地址,可不要搞错了。

sudo EXTERNAL_URL="http://192.168.1.128" yum install -y gitlab-jh

如果大家这里设置错误,可以到配置文件中修改:

 1. vim /etc/gitlab/gitlab.rb

external_url 'http://192.168.1.128:800'

nginx['listen_port'] = 800  ##这个是新添加的,用于nginx代理的端口

 2. vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml 

  gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    host: 192.168.1.128
    port: 800
    https: false

3.  vim /var/opt/gitlab/nginx/conf/gitlab-http.conf

server { ## HTTPS server
  listen *:800;

  server_name 192.168.1.128;
  server_tokens off; ## Don't show the nginx version number, a security best practice

  ## Increase this if you want to upload large attachments
  ## Or if you want to accept large git objects over http
  client_max_body_size 0;

最后,重载配置、重启即可

重载配置: gitlab-ctl reconfigure
重启:gitlab-ctl restart

(6)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                   # 查看日志;

(7)密码修改

启动成功后,我们除非在安装过程中指定了自定义密码,否则将随机生成一个密码并存储在 `/etc/gitlab/initial_root_password` 文件中(出于安全原因,24 小时后,此文件会被第一次 `gitlab-ctl reconfigure` 自动删除,因此若使用随机密码登录,建议安装成功初始登录成功之后,立即修改初始密码)。使用此密码和用户名 `root` 登录。

 vim /etc/gitlab/initial_root_password

获取密码在页面(http://192.168.1.128:800/users/sign_in)登陆后修改,注意用户名为root

保存后重启登陆即可。

三、创建一个GitLab项目

 创建一个空白项目

 设置项目名称等相关信息

创建完成后,会提示该项目的地址,复制该地址。 

在idea中创建项目,并添加到GitLab中,在VCS下 

 选择要提交的项目

 

输入提交信息,点击Commit and Push 

 

在弹出框中输入 url (这个url即为上面的GitLab项目地址url)

http://192.XX.1.XX:800/XXX/java-project.git

然后在弹出框中输入用户名和密码 (即为安装GitLab时候的用户名 root 和密码 )

 在GitLab中查看,注意,默认提交到master分支中 

可以合并分支

未完待续...

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值