ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Jenkins+Docker+SpringCloud微服务持续集成(三)

2022-03-06 22:01:06  阅读:232  来源: 互联网

标签:git url SpringCloud URL tensquare SonarQube sonar Jenkins Docker


链接:https://pan.baidu.com/s/1HR3Q-cojnCidRy1xrdlOxg
提取码:7m56
--来自百度网盘超级会员V3的分享

微服务持续集成(1)-项目代码上传到Gitlab
在IDEA操作即可,参考之前的步骤。包括后台微服务和前端web网站代码
image
image
image

先做后端提交
后端项目先提交给本地git
image
image
image

新定义远程仓库地址
image
image

复制gitlab中tensquare_back项目中http的URL

提交完成后,查看gitlab
image

Windows本地安装TortoiseGit(小乌龟)用来提交前端项目代码

安装中文汉化包

右击小乌龟git打开设置提交远程URL(前端项目的URL)
image
image

查看gitlab的tensquare_front项目
image

微服务持续集成(2)-从Gitlab拉取项目源码
1)创建Jenkinsfile文件

Jenkinsfile中的内容

点击查看代码
//git的凭证
def git_auth="1be38991-873b-4a68-8eb6-312347fdc0a4"
//git的URL
def git_url="git@192.168.195.180:devops_group/tensquare_back.git"
node {
    stage('pull code') {
        //切换成变量,字符串符号使用双引号
        checkout([$class: 'GitSCM', branches: [[name: "*/${branch}"]], extensions: [], userRemoteConfigs: [[credentialsId: "${git_auth}", url: "${git_url}"]]])
    }
}

在Jenkins服务器上查看构建项目
image

微服务持续集成(3)-提交到SonarQube代码审查
1)创建项目,并设置参数
创建tensquare_back项目,添加一个选择参数
image
image

每个项目的根目录下添加sonar-project.properties

点击查看代码
# must be unique in a given SonarQube instance
sonar.projectKey=tensquare_eureka_server
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=tensquare_eureka_server 
sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set. sonar.sources=. 
sonar.exclusions=**/test/**,**/target/** 
sonar.java.binaries=.
sonar.java.source=1.8 
sonar.java.target=1.8 

#sonar.java.libraries=**/target/classes/**
# Encoding of the source code. Default is default system encoding 
sonar.sourceEncoding=UTF-8

注意:修改sonar.projectKey和sonar.projectName

3)修改Jenkinsfile构建脚本

点击查看代码
//git的凭证
def git_auth="1be38991-873b-4a68-8eb6-312347fdc0a4"
//git的URL
def git_url="git@192.168.195.180:devops_group/tensquare_back.git"
node {
    stage('pull code') {
        //切换成变量,字符串符号使用双引号
        checkout([$class: 'GitSCM', branches: [[name: "*/${branch}"]], extensions: [], userRemoteConfigs: [[credentialsId: "${git_auth}", url: "${git_url}"]]])
    }
    stage('check code') {
            //定义SonarQubeScanner工具
            def scannerHome = tool 'sonar-scanner'
            //引用SonarQube系统环境
            withSonarQubeEnv('sonarqube') {
            sh """
                cd ${project_name}
                ${scannerHome}/bin/sonar-scanner
               """
               }
    }
}

再次构建进行代码检查

检查结果
image

随后把服务网关、认证中心和活动微服务都进行检查
image

标签:git,url,SpringCloud,URL,tensquare,SonarQube,sonar,Jenkins,Docker
来源: https://www.cnblogs.com/Rui-Lin/p/15957072.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有