创建Dockerfile
FROM openjdk:21
VOLUME /tmp
ADD springboot3-0.0.1-SNAPSHOT.jar app.jar
EXPOSE 8888
ENTRYPOINT ["java","-jar","/app.jar","--spring.cloud.nacos.server-addr=192.168.8.11:8848"]
新建一个【自由风格】项目
选择JDK版本
填写git信息
创建【调用顶层Maven目标】
clean package -Dmaven.test.skip=true
cd /root/.jenkins/workspace/Test1/target
cp /home/deploy/springboot3/Dockerfile /root/.jenkins/workspace/Test1/target/
docker stop springboot3 || true
docker rm springboot3 || true
docker rmi springboot3 || true
docker build -t springboot3 .
docker run -d -p 8888:15003 --name springboot3 springboot3:latest