Docker容器化CICD(下)
容器化maven 配合 sonar
############## docker拉取sonar pqsql ############
docker pull sonarqube ---- jdk 17
docker pull sonarqube ---- jdk 11
docker pull postgresql
############### 方法一 jdk11 ############## 映射maven命令到 jenkins中
## 缺陷
jdk 版本受限制 jdk版本为11 最新版的sonar需要jdk17 需要老版的sonar
# 下载maven (2进制版本) 解压 配置maven源
https://maven.apache.org/download.cgi
https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz
[root@docker03 app]# tar xf apache-maven-3.9.9-bin.tar.gz
[root@docker03 app]# mv apache-maven-3.9.9/ maven
[root@docker03 conf]# vim settings.xml
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>
# 映射maven的工作目录
docker run \
--name jenkins \
--privileged \
--user=root \
--restart=always \
-v /app/maven:/app/maven \
-v /data/jenkins/:/var/jenkins_home \
-v /usr/bin/docker:/usr/bin/docker \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /root/.ssh/:/root/.ssh/ \
-v /root/.docker/config.json:/root/.docker/config.json \
-p 8080:8080 \
-p 50000:50000 \
-d jenkins/jenkins:2.422
### 检查jenkins 中的maven 是否正确
# cd /app/maven/bin
# ./mvn -v
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /app/maven
Java version: 11.0.20, vendor: Eclipse Adoptium, runtime: /opt/java/openjdk
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.el7.x86_64", arch: "amd64", family: "unix"
#### 在jenkins中配置maven
############ 方法二 jdk17 #############