问题描述
Jenkinsfile使用k8s agent构建失败
jenkins报错截图:
查看pod app-system-23-wmx8b-5lnl2-lxvlr 的jnlp容器日志:
分析处理
一般构建失败大都是jnlp容器问题。
经以下日志分析发现jenkins主节点和slave节点的jdk版本不一致导致该提示Java JDK版本不对:
hudson/slaves/SlaveComputer$SlaveVersion has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
查看主节点jdk版本:
主节点的jdk版本为jdk11,那么slave节点jnlp镜像也应该是11版本,换成jenkins/jnlp-slave:4.13.3-1-jdk11重新构建即可
pipeline {
agent {
kubernetes {
cloud 'k8s'
slaveConnectTimeout 1200
yaml '''
apiVersion: v1
kind: Pod
spec:
nodeSelector:
build: "true"
containers:
- name: jnlp
args: [\'$(JENKINS_SECRET)\', \'$(JENKINS_NAME)\']
image: 'registry.cn-zhangjiakou.aliyuncs.com/public-shide/jnlp-slave:4.13.3-1-jdk11'
imagePullPolicy: IfNotPresent
- name: "build"
command:
- "cat"
image: "registry.cn-zhangjiakou.aliyuncs.com/public-shide/maven:3.5.3"
imagePullPolicy: "IfNotPresent"
tty: true
......
标签:jnlp,terminated,Code,slave,version,版本,Java,节点
From: https://blog.51cto.com/u_14843781/7061045