Jenkins+Gitlab+Sonar代码检查平台搭建-Maven

安装Maven

tar -zvxf apache-maven-3.3.9-bin.tar.gz -C /usr/local/src/

这一段要改

      <id>sonarid>

      <activation>
        <activeByDefault>trueactiveByDefault>
      activation>
      
     <properties>
       <sonar.jdbc.url>jdbc:mysql://localhost:3306/sonar?useUnicode=true;characterEncoding=utfsonar.jdbc.url>
       <sonar.jdbc.username>sonarsonar.jdbc.username>
       <sonar.jdbc.password>******sonar.jdbc.password>
       <sonar.host.url>http://10.127.96.124:9000sonar.host.url>

    properties>
    profile>

本地的仓储路径记得改一改,默认在根目录下

 /data/path/to/local/repoRepository>

跑一个java:maven:project妥妥的。

mvn clean package
mvn sonar:sonar

Jenkins+Gitlab+Sonar代码检查平台搭建-Maven_第1张图片

maven配置文件setting
我这边用的自己的私用库






<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">


  <localRepository>/data/path/to/local/repolocalRepository>


  

  

  
  <pluginGroups>
    
  pluginGroups>

  
  <proxies>
    
  proxies>

  
  <servers>
    

    
  servers>

  
   <mirrors>
    <mirror>
      <id>dingid>
      <mirrorOf>yunmirrorOf>
      <name>Human Readable Name for this Mirror.name>
      <url>http://10.142.164.239/nexus/content/url>
    mirror>
   mirrors>
  
  <profiles>
    
    <profile>
      <id>sonarid>

      <activation>
        <activeByDefault>trueactiveByDefault>
      activation>
      
     <properties>
       <sonar.jdbc.url>jdbc:mysql://localhost:3306/sonar?useUnicode=true;characterEncoding=utfsonar.jdbc.url>
       <sonar.jdbc.username>sonarsonar.jdbc.username>
       <sonar.jdbc.password>******sonar.jdbc.password>
       <sonar.host.url>http://10.127.96.124:9000sonar.host.url>

    properties>
    profile>

    
     <profile>  
      <id>profile-nexusid> 
      <repositories>  
        <repository>  
          <id>nexusid>  
          <url>http://10.142.164.239/nexus/content/groups/public/url>  
          <snapshots><enabled>trueenabled>snapshots>  
          <releases><enabled>trueenabled>releases>  
        repository>  
      repositories>  
      <pluginRepositories>  
        <pluginRepository>  
          <id>nexusid>  
          <url>http://10.142.164.239/nexus/content/groups/public/url>  
          <snapshots><enabled>trueenabled>snapshots>  
          <releases><enabled>trueenabled>releases>  
        pluginRepository>  
      pluginRepositories>  
    profile>  
  profiles>  

 <activeProfiles>  
  <activeProfile>profile-nexusactiveProfile>  
activeProfiles>   
settings>

你可能感兴趣的:(持续可集成)