通过pipeline配置sonar自动化实现过程解析

这篇文章主要介绍了通过pipeline配置sonar自动化实现过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

1.sonar配置webhooks,

通过pipeline配置sonar自动化实现过程解析_第1张图片

2.url填写jenkins的地址:http://jenkinsurl/sonarqube-webhook/

通过pipeline配置sonar自动化实现过程解析_第2张图片

3.前提:jenkins配置好sonar的scanner服务地址

node { 
  stage('gitcheckout') { 
    echo 'This is a gitcheckout step' 
        checkout poll: false, scm: [$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'git-', url: 'http://gitlab..com/qingzhu-dev/workflow.git']]]
  }
  stage('sonar') { 
     echo 'This is a sonar step' 
     def sonarqubeScannerHome = tool name: 'sonar-scanner'
     echo sonarqubeScannerHome
        withSonarQubeEnv('sonar') {
        sh "${sonarqubeScannerHome}/bin/sonar-scanner -X "+
        "-Dsonar.host.url=${SONAR_HOST_URL} " +
        "-Dsonar.language=java " + 
        "-Dsonar.projectKey=workflow " + 
        "-Dsonar.projectName=workflow " + 
        "-Dsonar.projectVersion=$BUILD_NUMBER " + 
        "-Dsonar.sources=src/ " + 
        "-Dsonar.sourceEncoding=UTF-8 " + 
        "-Dsonar.java.binaries=target/ " + 
        "-Dsonar.exclusions=src/test/** " 
        
     }
  }
  stage("QualityGate") {
    echo 'QualityGate'
    // timeout(time: 1, unit: "HOURS") {    // 防止获取回调出现异常情况,设置超时时间
    //   def qg = waitForQualityGate()
    //   if (qg.status != 'OK') {
    //     error "Pipeline aborted due to quality gate failure: ${qg.status}"
    //   }
    // }
  }

  stage('Build') { 
    echo 'This is a build step'
    sh "/var/jenkins_home/apache-maven-3.6.0/bin/mvn clean package -U dockerfile:build dockerfile:push -Ptest -D maven.test.skip=true -f pom.xml -Dimage.tag=v$BUILD_NUMBER"
  }
   stage('Deploy') { 
    echo 'This is a deploy step'  
    sh "${dp}"
  }
  stage('Test') { 
    echo 'This is a test step' 
        checkout poll: false, scm: [$class: 'GitSCM', branches: [[name: '*/qiaojiafei']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'git-', url: 'http://gitlab..com/qz-qa/qingzhucrmtest.git']]]
        sh '/var/jenkins_home/apache-maven-3.6.0/bin/mvn clean test -DfailIfNoTests=false -Ptest'
  }
stage('report'){    echo 'This is a report'      allure includeProperties: false, jdk: 'jdk1.8', results: [[path: 'allure-results']]    sh 'rm -rf allure-report'    sh 'rm -rf allure-results'  }  stage('email'){    emailext body: 'test', subject: 'test', to: '[email protected]'  }

}

最后

如果你想学习自动化测试,那么下面这套视频应该会帮到你很多

如何逼自己1个月学完自动化测试,学完即就业,小白也能信手拈来,拿走不谢,允许白嫖....

最后我这里给你们分享一下我所积累和整理的一些文档和学习资料,有需要直接领取就可以了!


以上内容,对于软件测试的朋友来说应该是最全面最完整的备战仓库了,为了更好地整理每个模块,我也参考了很多网上的优质博文和项目,力求不漏掉每一个知识点,很多朋友靠着这些内容进行复习,拿到了BATJ等大厂的offer,这个仓库也已经帮助了很多的软件测试的学习者,希望也能帮助到你。

​​

​​​​

你可能感兴趣的:(软件测试,自动化测试,selenium,python)