SonarQube与GitLab集成实现提交前代码扫描

1.安装gitlab
yum update
yum -y install epel-release curl vim policycoreutils-python
yum install -y postfix
systemctl enable sshd
systemctl enable postfix.service
systemctl start postfix
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
EXTERNAL_URL=“http://gitlab.example.com” yum install -y gitlab-ce
vim /etc/gitlab/gitlab.rb
systemctl stop firewalld.service
systemctl disable firewalld.service
gitlab-ctl reconfigure
2.安装sonarquber
这里如果有安装docker你可以直接跑sonarquber的docker镜像(docker run --name sq sonarquber )或者就按部就班的安装。先配置JDK,在安装MySQL,再配置sonar,这里我就不一一详细写了
3.配置 GitLab 通用账户
首先需要登录开发人员和设计人员的GitLab账户,获取个人的Token,如果没有Token,可以新建一个
SonarQube与GitLab集成实现提交前代码扫描登录SonarQube账户,配置GitLab地址和账户Token信息,
SonarQube与GitLab集成实现提交前代码扫描
4.配置 sonar-gitlab-plugin 插件;
将sonar-gitlab-plugin-4.0.0.jar包放在$SONAR_HOME/extensions/plugin/ 目录下
5.配置 gitlab-runner;
登录到安装有GitLab Runner的服务器,注册GitLab Runner
SonarQube与GitLab集成实现提交前代码扫描6.编写gitlab-ci.yaml 文件
SonarQube与GitLab集成实现提交前代码扫描
之后开发每次在gitlab上commit代码的时候都会触发扫描