我正在尝试使用自定义图像在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的插件默认映像是即时的。关于如何正确设置这些的任何想法或任何工作教程? 谢谢
答案 0 :(得分:0)
您需要更新 jenkinsfile 中的 POD_LABEL: 节点(POD_LABEL){ 这应该使用您的 pod 标签名称更新为 节点(jnlp-slave){