![](/img/trans.png)
[英]ChromeHeadless hangs when running karma tests inside Jenkins agent docker image (with Kubernetes plugin)
[英]Configure Kubernetes plugin Jenkins with custom agent image
我正在尝试使用自定义映像在 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 的插件默认映像是实例化的。 关于如何正确设置这些的任何想法或任何工作教程? 谢谢
您需要在 jenkinsfile 中更新 POD_LABEL: node(POD_LABEL) { 这应该使用您的 pod 标签名称更新为 node(jnlp-slave) {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.