一、Jenkins.job编译生成spring-cloud-demo的镜像文件
### --- Jenkins.job编译生成spring-cloud-demo的镜像文件~~~     # 创建完成之后会在k8s中创建一个pod,这个pod就是在pipeline指定的模板文件
~~~     # 执行完成之后这个pod会被清理掉,无论是成功还是失败都会被清理掉
~~~     Jenkins——>spring-cloud-demo——>Build with Parameters——>BRANCH:pipeline-test
~~~     ——>BUILD_COMMAND:mvn clean package-Dskip Tests——>Build——>END

二、查看构建pipeline的blue ocean
三、查看构建的pod

### --- 查看构建的pod[root@k8s-master01 ~]# kubectl get po -owide
NAME                                     READY   STATUS              RESTARTS   AGE   IP               NODE           NOMINATED NODE   READINESS GATES
spring-cloud-demo-20-3kb3k-z04hq-15hgg   4/4     Running              29s          12s   172.25.244.218   k8s-master01   <none>           <none>

四、查看pipeline构建记录
### --- 查看pipeline构建流水线过程
~~~     Dashboard——>spring-cloud-demo——>1~~~     # pod构建阶段
SuccessConsole Output
Started by user admin
Obtained Jenkinsfile from git git@gitlab.test.com:kubernetes-guide/jenkinsfile.git
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] podTemplate
[Pipeline] {
[Pipeline] node
Created Pod: kubernetes-default default/spring-cloud-demo-23-4krv0-ttxdl-5qfwx
Still waiting to schedule task
‘spring-cloud-demo-23-4krv0-ttxdl-5qfwx’ is offline
Agent spring-cloud-demo-23-4krv0-ttxdl-5qfwx is provisioned from template spring-cloud-demo_23-4krv0-ttxdl
---
~~~     # 创建pod的yaml文件,新版的jenkins会打印出来,旧版本不会打印
apiVersion: "v1"
kind: "Pod"
metadata:annotations:buildUrl: "http://192.168.1.14:28080/job/spring-cloud-demo/23/"runUrl: "job/spring-cloud-demo/23/"labels:jenkins: "slave"jenkins/label-digest: "1f94b9f257b20ca7402eca8f97ee31157892e86b"jenkins/label: "spring-cloud-demo_23-4krv0"name: "spring-cloud-demo-23-4krv0-ttxdl-5qfwx"
spec:containers:- command:- "cat"env:- name: "LANGUAGE"value: "en_US:en"- name: "LC_ALL"value: "en_US.UTF-8"- name: "LANG"value: "en_US.UTF-8"image: "registry.cn-beijing.aliyuncs.com/citools/maven:3.5.3"imagePullPolicy: "IfNotPresent"name: "build"tty: truevolumeMounts:- mountPath: "/etc/localtime"name: "volume-2"readOnly: false- mountPath: "/root/.m2/"name: "volume-maven-repo"readOnly: false- mountPath: "/etc/hosts"name: "volume-hosts"readOnly: false- mountPath: "/home/jenkins/agent"name: "workspace-volume"readOnly: false- command:- "cat"env:- name: "LANGUAGE"value: "en_US:en"- name: "LC_ALL"value: "en_US.UTF-8"- name: "LANG"value: "en_US.UTF-8"image: "registry.cn-beijing.aliyuncs.com/citools/kubectl:self-1.17"imagePullPolicy: "IfNotPresent"name: "kubectl"tty: truevolumeMounts:- mountPath: "/etc/localtime"name: "volume-2"readOnly: false- mountPath: "/var/run/docker.sock"name: "volume-docker"readOnly: false- mountPath: "/mnt/.kube/"name: "volume-kubeconfig"readOnly: false- mountPath: "/etc/hosts"name: "volume-hosts"readOnly: false- mountPath: "/home/jenkins/agent"name: "workspace-volume"readOnly: false- args:- "$(JENKINS_SECRET)"- "$(JENKINS_NAME)"env:- name: "JENKINS_SECRET"value: "********"- name: "JENKINS_AGENT_NAME"value: "spring-cloud-demo-23-4krv0-ttxdl-5qfwx"- name: "JENKINS_NAME"value: "spring-cloud-demo-23-4krv0-ttxdl-5qfwx"- name: "JENKINS_AGENT_WORKDIR"value: "/home/jenkins/agent"- name: "JENKINS_URL"value: "http://192.168.1.14:28080/"image: "registry.cn-beijing.aliyuncs.com/citools/jnlp:alpine"imagePullPolicy: "IfNotPresent"name: "jnlp"resources:limits: {}requests:memory: "256Mi"cpu: "100m"volumeMounts:- mountPath: "/etc/localtime"name: "volume-2"readOnly: false- mountPath: "/etc/hosts"name: "volume-hosts"readOnly: false- mountPath: "/home/jenkins/agent"name: "workspace-volume"readOnly: false- command:- "cat"env:- name: "LANGUAGE"value: "en_US:en"- name: "LC_ALL"value: "en_US.UTF-8"- name: "LANG"value: "en_US.UTF-8"image: "registry.cn-beijing.aliyuncs.com/citools/docker:19.03.9-git"imagePullPolicy: "IfNotPresent"name: "docker"tty: truevolumeMounts:- mountPath: "/etc/localtime"name: "volume-2"readOnly: false- mountPath: "/var/run/docker.sock"name: "volume-docker"readOnly: false- mountPath: "/etc/hosts"name: "volume-hosts"readOnly: false- mountPath: "/home/jenkins/agent"name: "workspace-volume"readOnly: falsenodeSelector:build: "true"restartPolicy: "Never"securityContext: {}volumes:- hostPath:path: "/usr/share/zoneinfo/Asia/Shanghai"name: "volume-2"- hostPath:path: "/opt/m2"name: "volume-maven-repo"- hostPath:path: "/etc/hosts"name: "volume-hosts"- hostPath:path: "/var/run/docker.sock"name: "volume-docker"- emptyDir:medium: ""name: "workspace-volume"- name: "volume-kubeconfig"secret:secretName: "multi-kube-config"
~~~     # 构建流水线阶段
Running on spring-cloud-demo-23-4krv0-ttxdl-5qfwx in /home/jenkins/agent/workspace/spring-cloud-demo
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
Selected Git installation does not exist. Using Default
The recommended git tool is: NONE
using credential 7a1ce79d-acbe-443c-b500-0971c05b9cdf
Cloning the remote Git repository
Cloning repository git@gitlab.test.com:kubernetes-guide/jenkinsfile.git> git init /home/jenkins/agent/workspace/spring-cloud-demo # timeout=10
Fetching upstream changes from git@gitlab.test.com:kubernetes-guide/jenkinsfile.git> git --version # timeout=10> git --version # 'git version 2.20.1'
using GIT_SSH to set credentials gitlab key> git fetch --tags --force --progress -- git@gitlab.test.com:kubernetes-guide/jenkinsfile.git +refs/heads#/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
Checking out Revision b827d2dbb359cc9ef530188f54dbe0f353f69319 (refs/remotes/origin/java-pipeline)> git config remote.origin.url git@gitlab.test.com:kubernetes-guide/jenkinsfile.git # timeout=10> git config --add remote.origin.fetch +refs/heads#/*:refs/remotes/origin/* # timeout=10> git rev-parse refs/remotes/origin/java-pipeline^{commit} # timeout=10> git config core.sparsecheckout # timeout=10> git checkout -f b827d2dbb359cc9ef530188f54dbe0f353f69319 # timeout=10
Commit message: "Update Jenkinsfile"> git rev-list --no-walk b827d2dbb359cc9ef530188f54dbe0f353f69319 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (pulling Code)
[Pipeline] parallel
[Pipeline] { (Branch: pulling Code)
[Pipeline] { (Branch: pulling Code by trigger)
[Pipeline] stage
[Pipeline] { (pulling Code)
[Pipeline] stage
[Pipeline] { (pulling Code by trigger)
Stage "pulling Code by trigger" skipped due to when conditional
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] git
The recommended git tool is: NONE
using credential 7a1ce79d-acbe-443c-b500-0971c05b9cdf
Fetching changes from the remote Git repository> git rev-parse --resolve-git-dir /home/jenkins/agent/workspace/spring-cloud-demo/.git # timeout=10> git config remote.origin.url git@gitlab.test.com:kubernetes-guide/spring-cloud-demo.git # timeout=10
Fetching upstream changes from git@gitlab.test.com:kubernetes-guide/spring-cloud-demo.git> git --version # timeout=10> git --version # 'git version 2.20.1'
using GIT_SSH to set credentials gitlab key> git fetch --tags --force --progress -- git@gitlab.test.com:kubernetes-guide/spring-cloud-demo.git +refs/heads#/*:refs/remotes/origin/* # timeout=10
Checking out Revision f0cefa762f2234ac55191581c05265d767f9eee8 (refs/remotes/origin/pipeline-test)
Commit message: "added Dockerfile"> git rev-parse refs/remotes/origin/pipeline-test^{commit} # timeout=10> git config core.sparsecheckout # timeout=10> git checkout -f f0cefa762f2234ac55191581c05265d767f9eee8 # timeout=10> git branch -a -v --no-abbrev # timeout=10> git checkout -b pipeline-test f0cefa762f2234ac55191581c05265d767f9eee8 # timeout=10> git rev-list --no-walk f0cefa762f2234ac55191581c05265d767f9eee8 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // parallel
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (initConfiguration)
[Pipeline] script
[Pipeline] {
[Pipeline] sh
+ git log -n 1 '--pretty=format:%h'
[Pipeline] sh
+ git log -1 '--pretty=format:%h : %an  %s'
[Pipeline] sh
+ date '+%Y%m%d-%H%M%S'
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Building)
[Pipeline] parallel
[Pipeline] { (Branch: Building)
[Pipeline] { (Branch: Scan Code)
[Pipeline] stage
[Pipeline] { (Building)
[Pipeline] stage
[Pipeline] { (Scan Code)
[Pipeline] container
[Pipeline] {
[Pipeline] sh
[Pipeline] sh
+ echo 'Scan Code'
Scan Code
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
+ echo Building Project...
Building Project...
~~~     # maven编译打包jar包过程
+ mvn clean package -DskipTests
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.zb:spring-cloud-eureka >---------------------
[INFO] Building spring-cloud-eureka 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ spring-cloud-eureka ---
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ spring-cloud-eureka ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ spring-cloud-eureka ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/jenkins/agent/workspace/spring-cloud-demo/target/classes
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ spring-cloud-eureka ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/jenkins/agent/workspace/spring-cloud-demo/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ spring-cloud-eureka ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/jenkins/agent/workspace/spring-cloud-demo/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ spring-cloud-eureka ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.1.2:jar (default-jar) @ spring-cloud-eureka ---
[INFO] Building jar: /home/jenkins/agent/workspace/spring-cloud-demo/target/spring-cloud-eureka-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.9.RELEASE:repackage (repackage) @ spring-cloud-eureka ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:51 min
[INFO] Finished at: 2021-06-20T09:09:44Z
[INFO] ------------------------------------------------------------------------
~~~     显示SUCCESS说明jar包编译打包完成,编译完成后会生成一个jar包,会执行build命令
~~~     # 执行build操作,将镜像推送到阿里云镜像仓库
[Pipeline] }
[Pipeline] // container
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // parallel
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build image)
~~~     注:切换到Build image,切换daodokcer容器中
[Pipeline] withCredentials                                          // 证书执行
Masking supported pattern matches of $Password
[Pipeline] {
[Pipeline] container
[Pipeline] {
[Pipeline] sh
+ docker build -t registry.cn-beijing.aliyuncs.com/java-demo-yanqi/spring-cloud-demo-eureka:20210620-170745-f0cefa7-pipeline-test .
Sending build context to Docker daemon  89.63MB
~~~     # 注:执行build操作
Step 1/3 : FROM registry.cn-beijing.aliyuncs.com/citools/maven:3.5.3---> 878388a112cc
Step 2/3 : COPY target#/*.jar /opt---> b89b04bd84fb
Step 3/3 : EXPOSE 8080---> Running in 6a6c0d45519c
Removing intermediate container 6a6c0d45519c---> e46193a14e10
Successfully built e46193a14e10
Successfully tagged registry.cn-beijing.aliyuncs.com/java-demo-yanqi/spring-cloud-demo-eureka:20210620-170745-f0cefa7-pipeline-test
~~~     注:build执行完成,
+ docker login -u yanqi_vip -p **** registry.cn-beijing.aliyuncs.com
~~~     注:登录到阿里云的镜像残酷,账号密码是打***的,若是只写写入账号密码,非常不安全
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
~~~     # push操作,将镜像上传到阿里云镜像仓库
Login Succeeded
+ docker push registry.cn-beijing.aliyuncs.com/java-demo-yanqi/spring-cloud-demo-eureka:20210620-170745-f0cefa7-pipeline-test
The push refers to repository [registry.cn-beijing.aliyuncs.com/java-demo-yanqi/spring-cloud-demo-eureka]
7645b87ac52c: Preparing
2c5255233283: Waiting
6d6a0b8035f5: Pushed
a130cc33ffce: Retrying in 5 seconds
a130cc33ffce: Retrying in 4 seconds
6e71e5d88701: Retrying in 2 seconds
6e71e5d88701: Retrying in 1 second
4e2f09da8ad8: Pushed
20210620-170745-f0cefa7-pipeline-test: digest: sha256:26321300207d99a6ed1dfb5ffed85f4c77f4c4e520beb967a632829e8287fc94 size: 3048
[Pipeline] }
[Pipeline] // container
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Deploy)
Stage "Deploy" skipped due to when conditional
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
Finished: SUCCESS
~~~     # 流水线构建成功

五、查看阿里云镜像版本库中推送的spring-cloud-demo的镜像文件

CC00384.CloudKubernetes——|KuberNetesCI/CD.V22|——|Jenkins.v02|自动构建Java应用.v02|相关推荐

  1. CC00388.CloudKubernetes——|KuberNetesCI/CD.V26|——|Jenkins.v06|自动构建Java应用.v06|报错处理|

    附录一:报错处理一: ### --- 报错现象+ echo Building Project... Building Project... + mvn clean package-Dskip Test ...

  2. CC00385.CloudKubernetes——|KuberNetesCI/CD.V23|——|Jenkins.v03|自动构建Java应用.v03|

    一.创建spring-cloud-demo的资源文件 ### --- 创建spring-cloud-demo的namespace:java-test ~~~ 创建namespace[root@k8s- ...

  3. CC00389.CloudKubernetes——|KuberNetesCI/CD.V27|——|Jenkins.v07|自动构建NodeJs应用.v01|

    一.创建nodejs-Jenkinsfile ### --- 新建分支:node-pipeline~~~ 新建分支:node-pipeline:+号-->New branch-->Bran ...

  4. CC00399.CloudKubernetes——|KuberNetesCI/CD.V37|——|Jenkins.v03|生产UAT流水线设计.v03|

    一.在jenkins下创建job ### --- 创建view item~~~ Jenkins-->Dashboard-->+号-->View name:uat--> List ...

  5. CC00382.CloudKubernetes——|KuberNetesCI/CD.V20|——|Jenkins.v08|kubeconfig多集群配置.v02|

    一.查看k8s集群配置 ### --- 查看kubeconfig文件配置信息[root@k8s-master01 ~]# cat ~/.kube/config apiVersion: v1 clust ...

  6. CC00365.CloudKubernetes——|KuberNetesCI/CD.V03|——|Jenkins.v03|初始化.v03|

    一.Jenkins初始化:Jenkins初始化配置 ### --- 获取初始密码[root@k8s-node01 CICD]# cat /root/.jenkins/secrets/initialAd ...

  7. CC00407.CloudKubernetes——|KuberNetesCI/CD.V45|——|Jenkins.v11|SpringCloud_Eureka.v05|

    一.SpringCloud项目总结 ### --- SpringCloud:~~~ 只是一个架构,部署也是单独应用去部署的. ~~~ 和java容器化是没有什么区别的 ~~~ 主要是组件:Eureka ...

  8. 怎么把项目推到gitlab上_Gitlab利用Webhook+jenkins实现自动构建与部署

    之前部署了Gitlab的代码托管平台和Jenkins的代码发布平台.通常是开发后的代码先推到Gitlab上管理,然后在Jenkins里通过脚本构建代码发布. 这种方式每次在发版的时候,需要人工去执行j ...

  9. gitlab 自动推送代码到gitee_Gitlab 利用 Webhook+jenkins 实现自动构建与部署

    之前部署了Gitlab的代码托管平台和Jenkins的代码发布平台.通常是开发后的代码先推到Gitlab上管理,然后在Jenkins里通过脚本构建代码发布. 这种方式每次在发版的时候,需要人工去执行j ...

最新文章

  1. 如何利用FineReport制作动态树报表
  2. QT的QReadLocker类的使用
  3. 如何真正提高ASP.NET网站的性能
  4. 【算法】剑指 Offer 61. 扑克牌中的顺子 【重刷】
  5. MT4红绿柱黄白线双线MACD指标
  6. PDF控件Aspose.Pdf 12月新版17.12发布 | 附下载
  7. Flash CS4学习笔记1
  8. 学生网页作业——仿华为手机电子商城 (1页) HTML+CSS+JavaScript html网页制作期末大作业成品_网页设计期末作业
  9. 计算机硬盘格式化三个步骤,格式化计算机的硬盘驱动器步骤
  10. 嵌入式开发-Telink芯片-入门介绍
  11. xp系统从u盘启动计算机,一键u盘装xp系统,教您如何使用U盘装xp系统
  12. 涉及到的非线性滤波算法 -- 理解
  13. 聊聊旷厂黑科技 | 五彩斑斓的黑,旷视“算”出来了!
  14. 粤嵌实习-linux下madplay播放器的下载和使用、线程的介绍和创建一个广告循环播放线程
  15. 酷派改变者S1(C105/C105-6/C105-8) 解锁BootLoader 并刷入recovery root
  16. Mac的最新版本JDK下载失败的解决方法
  17. 计算机配置价格对比,硬件配置、价格对比
  18. Spring AOP 之 多切面
  19. 大体重程序员的减肥经历(不完整待补充)
  20. 单核处理器、多核处理器、多处理器与多线程编程

热门文章

  1. JAVA学习 API_day02(正则表达式, StringBuider, 包装类, Collection集合类接口)
  2. sandboxie_在Sandboxie中运行应用程序以保持系统清洁和安全
  3. 内向交货和外向交货区别
  4. C语言逻辑运算符顺序
  5. css 菜鸟学习中!
  6. 紧致卷积网络设计——Shift卷积算子
  7. bilibili 视频云数据分析工程师笔试题(20200813)
  8. php和mysql的实践报告_PHP+MySQL项目开发与实践
  9. Android2018年必须知道的史上最全框架、最全开源App(高级开发人员必看,面试必看)
  10. PIC16F1829 单片机配置和DEMO CODE