前提需要在项目根目录下新建sonar-project.properties文件,内容如下:

# must be unique in a given SonarQube instance
sonar.projectKey=cynomys:0.0.
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=cynomys
sonar.projectVersion=0.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.source=1.8
sonar.java.target=1.8 # Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8
# 项目的class文件地址
sonar.java.binaries=/root/.jenkins/workspace/e-content/e-content-controller/target/classes

pipeline脚本

node {
maven_home='/usr/local/apache-maven-3.5.4' stage('Pull Code'){ git branch: 'master', credentialsId: 'gitlab_account', url: 'http://******.git' } stage('Code Check') {
echo "代码检查!"
} stage('SonarQube analysis') {
// SonarQubeServer为系统配置的SonarQube servers的名称
withSonarQubeEnv('SonarQubeServer') {
sh '/usr/local/sonar-scanner-3.2.0.1227-linux/bin/sonar-scanner' }
} stage('Unit Test') {
echo "单元测试 !"
} stage('Compile') {
echo '编译开始'
// 暂时打包报错
sh "'$maven_home'/bin/mvn install"
} stage('Build Images') {
echo '敬请期待!' } stage('Backup'){
echo '旧版本软件包已经备份'
} stage('Delete Old war'){
echo "删除老的包"
} stage('Deploy'){
echo '部署!'
sh 'echo hello'
// sh 'scp /root/.jenkins/workspace/e-trade/e-trade-mapper/target/e-trade-mapper-1.0-SNAPSHOT.jar root@10.132.131.51:/home/guchen_test' } stage('Integration Testing') {
echo "敬请期待!"
} stage('UI Automated Testing') {
echo "敬请期待!"
} stage('Send Testing Report') {
echo "敬请期待!"
} }

pipeline+sonar的更多相关文章

  1. Jenkins Pipeline+sonar构建质量平台

    前提: Jenkins JDK 目录: 1.安装sonar插件:SonarQube Scanner for Jenkins 2.安装SonarQube 3.安装sonar-scanner ++++++ ...

  2. pipeline配置sonar和自动化

    1.sonar配置webhooks, 2.url填写jenkins的地址:http://jenkinsurl/sonarqube-webhook/ 3.前提:jenkins配置好sonar的scann ...

  3. jenkins2 pipeline 语法快速参考

    jenkins2 pipeline中常用的语法快速参考. 文章来自:http://www.ciandcd.com文中的代码来自可以从github下载: https://github.com/ciand ...

  4. 在Jenkins中使用sonar进行静态代码检查

    要解决的问题 jenkins自动构建完成后,希望能通过sonar静态代码检查生成一份报告,给与开发人员对当前代码的做一个质量评估和修改意见 1.安装并配置sonar服务器 懒得说,跟着官方文档走就行, ...

  5. [持续交付实践] pipeline使用:项目样例

    项目说明 本文将以一个微服务项目的具体pipeline样例进行脚本编写说明.一条完整的pipeline交付流水线通常会包括代码获取.单元测试.静态检查.打包部署.接口层测试.UI层测试.性能专项测试( ...

  6. Jenkins Jfrog Artifactory 以及docker下的pipeline 容器编排实践

    1. 测试环境情况: Docker主机 10.24.101.99 JFrog Artifactory 主机 (admin password) jenkinx github原始地址:https://gi ...

  7. jenkins pipeline 部署

    一.git 版本控制结合jenkins 发布 sh-4.2$ git branch sh-4.2$ git chekout master sh-4.2$ git tag v1.1 sh-4.2$ gi ...

  8. Jenkins + Pipeline 构建流水线发布

      Jenkins + Pipeline 构建流水线发布 利用Jenkins的Pipeline配置发布流水线 参考: https://jenkins.io/doc/pipeline/tour/depl ...

  9. 看到了一个pipeline例子,

    pipeline { agent any options { timestamps() } parameters { string(name: 'GIT_BRANCH', defaultValue: ...

随机推荐

  1. 使用JAVA爬取京东商品价格

    有一件物品,你想看看它在京东下所有搜索结果的价格,要怎么办呢? 京东这个网站还是很好爬的,所有价格信息都写在了Html里面,而且跳到第二页之后,url也是有规律的,基本没有什么技术难度. 例如:想找i ...

  2. NetworkStream.write只能使用一次,后面再使用无效

    public delegate void ShowMessageMethod2(TcpClient tc); private void ShowMessage2(TcpClient tc) { Str ...

  3. delphi 选择文件夹,路径选择,浏览文件夹

    选择文件夹,路径选择, 文件夹 资源管理器 推荐  SelectDirectory http://docwiki.embarcadero.com/Libraries/Seattle/en/Vcl.Fi ...

  4. TestNG Hello World入门示例

    https://www.yiibai.com/testng/hello-world-example.html https://www.yiibai.com/testng/ 作为一个经典的入门例子,这里 ...

  5. java第三方类库实现图片等比缩放

    public class ThumbnailTest { public static void main(String[] args) { InputStream is = null; try { / ...

  6. 【原】Coursera—Andrew Ng机器学习—课程笔记 Lecture 10—Advice for applying machine learning 机器学习应用建议

    Lecture 10—Advice for applying machine learning 10.1 如何调试一个机器学习算法? 有多种方案: 1.获得更多训练数据:2.尝试更少特征:3.尝试更多 ...

  7. opencv3.4 win10 visual studio2017 opencv_contrib 编译

    found Intel IPP (ICV version): 2017.0.3 [2017.0.3] at: D:/opencv/opencv_3_4_0/opencv/my_build/3rdpar ...

  8. 安装操作系统CentOS-7.x

    一.创建虚拟机 使用VMware Fusion创建虚拟机 二.系统安装 为了统一环境,保证实验的通用性,将网卡名称设置为eth*,不使用CentOS 7默认的网卡命名规则.所以需要在安装的时候,增加内 ...

  9. Springboot-读取核心配置文件及自定义配置文件

    读取核心配置文件 核心配置文件是指在resources根目录下的application.properties或application.yml配置文件,读取这两个配置文件的方法有两种,都比较简单. 核心 ...

  10. 关于C++中不同类之间的赋值问题——存疑

    operator=不能重载为全局函数.理由如下 void operator=(int i , A& a) {  a.a = i } ; 那么将会出现 99 = a 这种代码,但是99不是左值, ...