我遇到了一个我不太明白的情况,我的代码似乎在错误的映像中执行--尽管日志声明它已经加载了我的映像。
预期输出与实际输出
当我运行docker run -it jstevnsvig/jenkins-build-slave-php:v8.2 /bin/sh -c "dpkg-query -l | cat"
时,我得到了预期的输出。
当我使用适当的标记运行Jenkins自由式作业时,通过执行dpkg-query -l | cat
的单个脚本步骤,我得到了我认为是在jnlp映像(jenkins/inbound-agent:3077.vd69cf116da_6f-3-jdk11
)中运行的输出。如何使它在正确的映像上运行?
Jenkins Kubernetes云Pod模板配置
Jenkins作业控制台
Started by user JoSSte
Running as SYSTEM
Agent php8-2dfd8 is provisioned from template php8
---
apiVersion: "v1"
kind: "Pod"
metadata:
labels:
jenkins: "slave"
jenkins/label-digest: "cb0616020c016c081bd72366740b4151da57f6a3"
jenkins/label: "php8"
name: "php8-2dfd8"
namespace: "devops-tools"
spec:
containers:
- args:
- "9999999"
command:
- "sleep"
image: "jstevnsvig/jenkins-build-slave-php:v8.2"
imagePullPolicy: "IfNotPresent"
name: "php8t"
resources: {}
tty: false
volumeMounts:
- mountPath: "/home/jenkins/agent"
name: "workspace-volume"
readOnly: false
workingDir: "/home/jenkins/agent"
- env:
- name: "JENKINS_PROTOCOLS"
value: "JNLP4-connect"
- name: "JENKINS_SECRET"
value: "********"
- name: "JENKINS_AGENT_NAME"
value: "php8-2dfd8"
- name: "JENKINS_DIRECT_CONNECTION"
value: "jenkins-service:50000"
- name: "JENKINS_INSTANCE_IDENTITY"
value: "..."
- name: "JENKINS_NAME"
value: "php8-2dfd8"
- name: "JENKINS_AGENT_WORKDIR"
value: "/home/jenkins/agent"
image: "jenkins/inbound-agent:3077.vd69cf116da_6f-3-jdk11"
name: "jnlp"
resources:
requests:
memory: "256Mi"
cpu: "100m"
volumeMounts:
- mountPath: "/home/jenkins/agent"
name: "workspace-volume"
readOnly: false
hostNetwork: false
nodeSelector:
kubernetes.io/os: "linux"
restartPolicy: "Never"
volumes:
- emptyDir:
medium: ""
name: "workspace-volume"
我尝试将容器模板的标签更改为jnlp
,但它无法正确连接(我的映像构建在jenkins/agent映像上)
1条答案
按热度按时间q5lcpyga1#
如本文所述,默认情况下,Jenkins代理中的命令将在
jnlp
容器中运行。如果您希望在podTemplate
中定义的另一个容器中运行这些命令,请使用container {..}
块(此处的部分)