一、Gitlab搭建
若无本地Gitlab,参考教程:https://blog.csdn.net/weixin_41668084/article/details/113817655
二、用户创建
若已有用户,直接登录,若无用户创建新的用户
2.1 登录用户
![image-20210216131828626](https://i-blog.csdnimg.cn/blog_migrate/3589dceedb762744f4d7d5de23c2b810.png)
2.2 创建新的用户
![image-20210216132054781](https://i-blog.csdnimg.cn/blog_migrate/695af9ab438148c62a012c040b1ed013.png)
2.3 登录初始页面
![image-20210216132934970](https://i-blog.csdnimg.cn/blog_migrate/74e9d9d8afafff1c3067434a623a5530.png)
三、项目创建
3.1 创建群组
![image-20210216133544217](https://i-blog.csdnimg.cn/blog_migrate/44f9fa130162a56a8cfcddebc74e2814.png)
![image-20210216133859781](https://i-blog.csdnimg.cn/blog_migrate/2ffffb2b66cfb87725be28153a16edc4.png)
3.2 创建项目
![image-20210216133951553](https://i-blog.csdnimg.cn/blog_migrate/70372ab915c4d9f8cb183876d616e229.png)
![image-20210216134114249](https://i-blog.csdnimg.cn/blog_migrate/7b9a77bb6c000bff1bf4cb9318f48aec.png)
3.3 添加SSH密钥
密钥生成可参考教程:https://blog.csdn.net/weixin_41668084/article/details/113820287
![image-20210216134213292](https://i-blog.csdnimg.cn/blog_migrate/f192622d4e559c93414fbf03b7f72b4b.png)
![image-20210216134521231](https://i-blog.csdnimg.cn/blog_migrate/2c2ff9b8c4c9b68f4fad2ec1b68533d5.png)
3.4 本地创建项目
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jenkins</groupId>
<artifactId>gitlab</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>gitlab</name>
<description>jenkins-gitlab project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.3.7.RELEASE</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>jenkins-gitlab</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.7.RELEASE</version>
<configuration>
<mainClass>com.jenkins.gitlab.GitlabApplication</mainClass>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
3.5 项目初始化
3.5.1 Git局部配置
#切换到项目路径下
git init
git config --local user.name "你的名称"
git config --local user.email "你的邮箱"
#查看本地信息
git config --local --list
3.5.2 项目推送
#连接远程仓库
git remote add origin http://192.168.61.72/test/gitlab-test.git
#添加所有文件
git add .
#提交代码
git commit -m "Initial commit"
#推送远程仓库
git push -u origin master
![image-20210216141319572](https://i-blog.csdnimg.cn/blog_migrate/c668ccfc3c89de7ba3ab9bbeb8b77052.png)
3.5.3 项目推送失败
3.5.3.1 问题现状
#git客户端使用ssh秘钥登录GitLab时提示permission denied please try again
git@192.168.61.72: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
3.5.3.2 问题解决
vi /etc/ssh/sshd_config
去掉注释 #
保存退出(Esc+:wq!)
重启ssh服务
service sshd restart
![image-20210220170345804](https://i-blog.csdnimg.cn/blog_migrate/2806378f06dbda1cda7d95627895b2b1.png)
![image-20210220170707667](https://i-blog.csdnimg.cn/blog_migrate/88652276e0562d2a72676eb32c731687.png)
3.6 创建分支
![image-20210216142409005](https://i-blog.csdnimg.cn/blog_migrate/f40a36454dd4a6aa55b17825e1da049a.png)
![image-20210216142516258](https://i-blog.csdnimg.cn/blog_migrate/1599b9d278f477eac4b02344e7f07983.png)
3.7 分支保护
![image-20210216142814735](https://i-blog.csdnimg.cn/blog_migrate/54094ef369fb4170962b4ef4158a3645.png)
![image-20210216143030889](https://i-blog.csdnimg.cn/blog_migrate/a9d749b0df5c4cb586e819dcc35cd897.png)
3.8 项目删除
![image-20210216132540240](https://i-blog.csdnimg.cn/blog_migrate/fb26ddc3b69d8335e503e98cfd6f4487.png)
3.9 组删除
![image-20210216132706876](https://i-blog.csdnimg.cn/blog_migrate/df5f20cbf2b67628ce0987504294f537.png)
3.10 成员添加
![image-20210216143223346](https://i-blog.csdnimg.cn/blog_migrate/b8a2eebe0360a03d7090494bae18b3e1.png)
以上,请参考!