yum install libtool-ltdl-2.4.2-22.el7_3.x86_64
jenkins-compose.yml完整内容如下:
version: '3'
networks:
prodnetwork:
driver: bridge
services:
sonardb:
image: postgres:12.2
restart: always
ports:
- "5433:5432"
networks:
- prodnetwork
volumes:
- /data/docker/ci/postgresql:/var/lib/postgresql
- /data/docker/ci/postgresql/data:/var/lib/postgresql/data
- /etc/localtime:/etc/localtime:ro
environment:
- POSTGRES_USER=sonar
- POSTGRES_PASSWORD=sonar
- POSTGRES_DB=sonar
- TZ=Asia/Shanghai
sonar:
image: sonarqube:10.1.0-community
restart: always
ports:
- "19000:9000"
- "19092:9092"
networks:
- prodnetwork
depends_on:
- sonardb
volumes:
- /data/docker/ci/sonarqube/conf:/opt/sonarqube/conf
- /data/docker/ci/sonarqube/data:/opt/sonarqube/data
- /data/docker/ci/sonarqube/logs:/opt/sonarqube/logs
- /data/docker/ci/sonarqube/extensions:/opt/sonarqube/extensions
- /data/docker/ci/sonarqube/bundled-plugins:/opt/sonarqube/lib/bundled-plugins
environment:
- TZ=Asia/Shanghai
- SONARQUBE_JDBC_URL=jdbc:postgresql://sonardb:5432/sonar
- SONARQUBE_JDBC_USERNAME=sonar
- SONARQUBE_JDBC_PASSWORD=sonar
jenkins:
image: jenkins/jenkins:lts
user: root
privileged: true
restart: always
ports:
- "18080:8080"
networks:
- prodnetwork
volumes:
- /usr/bin/docker:/usr/bin/docker
- /var/run/docker.sock:/var/run/docker.sock
- /etc/docker/daemon.json:/etc/docker/daemon.json
- /usr/lib64/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7
- /etc/localtime:/etc/localtime:ro
- $HOME/.ssh:/root/.ssh
- /data/docker/ci/jenkins/lib:/var/lib/jenkins/
- /data/docker/ci/jenkins/home:/var/jenkins_home
depends_on:
- sonar
environment:
- TZ=Asia/Shanghai
- NEXUS_PORT=8081
- SONAR_PORT=9000
- SONAR_DB_PORT=5432
- JAVA_OPTS=-Xms512m -Xmx10240m
deploy:
resources:
limits:
cpus: "2.00"
memory: 10G
reservations:
memory: 200M
cap_add:
- ALL
因并不是每个项目都需要自己的Maven私服,所以这里去除了Maven私服Nexus的部署,如果需要,直接在jenkins-compose.yml文件中添加即可:
nexus:
image: sonatype/nexus3
restart: always
ports:
- "18081:8081"
networks:
- prodnetwork
volumes:
- /data/docker/ci/nexus:/nexus-data
在Jenkins的depends_on:添加
depends_on:
- nexus
- sonar
mkdir -p /data/docker/ci/nexus /data/docker/ci/jenkins/lib /data/docker/ci/jenkins/home /data/docker/ci/sonarqube /data/docker/ci/postgresql /data/docker/ci/postgresql/data
chmod -R 777 /data/docker/ci/nexus /data/docker/ci/jenkins/lib /data/docker/ci/jenkins/home /data/docker/ci/sonarqube /data/docker/ci/postgresql /data/docker/ci/postgresql/data
docker-compose -f jenkins-compose.yml up -d
docker-compose -f jenkins-compose.yml down
docker-compose -f jenkins-compose.yml up --force-recreate --no-deps 服务名称
[root@root server]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b28f1878ee08 jenkins/jenkins:lts "/sbin/tini -- /usr/…" 20 hours ago Up 19 hours 50000/tcp, 0.0.0.0:18080->8080/tcp docker-jenkins-1
cff7c0d88150 sonarqube:10.1.0-community "/opt/sonarqube/dock…" 20 hours ago Up 20 hours 0.0.0.0:19000->9000/tcp, 0.0.0.0:19092->9092/tcp docker-sonar-1
90dacc85efb1 postgres:12.2 "docker-entrypoint.s…" 20 hours ago Up 20 hours 0.0.0.0:5433->5432/tcp docker-sonardb-1
[root@root server]# docker logs -f b28f1878ee08
[root@root server]# docker restart b28f1878ee08
[root@ZvRiIw4706 docker]# cd /data/docker/ci/jenkins/home/secrets
[root@ZvRiIw4706 secrets]# ls
filepath-filters.d initialAdminPassword jenkins.model.Jenkins.crumbSalt master.key org.jenkinsci.main.modules.instance_identity.InstanceIdentity.KEY slave-to-master-security-kill-switch whitelisted-callables.d
[root@ZvRiIw4706 secrets]# cat initialAdminPassword
报错日志:
2023-08-09 07:44:36.664+0000 [id=72] INFO h.m.UpdateCenter$UpdateCenterConfiguration#download: Downloading github-branch-source
2023-08-09 07:44:36.685+0000 [id=72] SEVERE h.model.UpdateCenter$DownloadJob#run: Failed to install github-branch-source
java.io.IOException: Failed to load: GitHub Branch Source Plugin (1696.v3a_7603564d04)
- Failed to load: GitHub plugin (1.34.5)
- Jenkins (2.346.1) or higher required
at hudson.PluginWrapper.resolvePluginDependencies(PluginWrapper.java:1016)
at hudson.PluginManager.dynamicLoad(PluginManager.java:917)
Caused: java.io.IOException: Failed to install github-branch-source plugin
at hudson.PluginManager.dynamicLoad(PluginManager.java:930)
at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:2179)
Caused: java.io.IOException: Failed to dynamically deploy this plugin
at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:2183)
at hudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:1846)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at hudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:121)
at java.base/java.lang.Thread.run(Thread.java:829)
-Xms256m -Xmx512m -XX:MaxPermSize=128m -XX:ReservedCodeCacheSize=64m
NodeJS安装,选择自己所需要的版本,同时如果有其他工具包可以在下方填写,比如我们使用的是pnpm,使用的镜像源是https://registry.npm.taobao.org ,可以在下方填写:
pnpm -registry=https://registry.npm.taobao.org
Gitee: https://gitee.com/wmz1930/GitEgg
GitHub: https://github.com/wmz1930/GitEgg