我试图在Jenkins中使用自定义图像配置kubernetes插件,但是当我启动管道时,我得到了这个错误:
Started by user unknown or anonymous
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] podTemplate
[Pipeline] {
[Pipeline] node
Still waiting to schedule task
‘testjenkinsslaveagent-54-blfkj-1zp9j-lbn6q’ is offline其中testjenkinsslaveagent是我的管道名称。Kubernetes插件配置如下:

流水线si定义如下:
podTemplate(containers: [
containerTemplate(name: 'jnlp', image: 'registry.gitlab.com/xxxx/dockerimages:latest', ttyEnabled: true, command: '/bin/sh'),
],volumes: [hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock')]) {
node(POD_LABEL) {
stage('Run') {
container('my-slave') {
sh 'echo hello world'
sh 'ifconfig'
sh 'sudo docker images ls'
}
}
}
}Jenkins的版本是2.176.3,所有插件都更新了。
由于我需要在代理中使用docker,所以我修改了一个现有的Dockerimage,如下所示(它在本地工作):
ARG version=4.0.1-1
FROM jenkins/slave:$version
ARG version
MAINTAINER Oleg Nenashev <o.v.nenashev@gmail.com>
LABEL Description="This is a base image, which allows connecting Jenkins agents via JNLP protocols" Vendor="Jenkins project" Version="$version"
ARG user=jenkins
USER root
COPY jenkins-agent /usr/local/bin/jenkins-agent
RUN chmod +x /usr/local/bin/jenkins-agent &&\
ln -s /usr/local/bin/jenkins-agent /usr/local/bin/jenkins-slave
# Install docker routine
RUN echo 'Installing docker routine ...'
RUN apt-get update && \
apt-get -y install apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common && \
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && \
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) \
stable" && \
apt-get update && \
apt-get -y install docker-ce
RUN usermod -a -G docker jenkins
RUN mkdir -p /home/jenkins/.ssh && \
chown -R 1000:1000 /home/jenkins/.ssh
USER ${user}
ENTRYPOINT ["jenkins-agent"]问题是我的自定义代理docker镜像被忽略了,Kubertete的插件默认镜像是实例化的。有没有关于如何正确设置这些的想法或任何工作指南?谢谢
发布于 2021-04-09 14:14:33
您需要更新jenkinsfile中的从属文件: node( POD_LABEL ) {这应该更新为您的pod标签名称为node(jnlp-POD_LABEL){
https://stackoverflow.com/questions/60622816
复制相似问题