We have configured two Kubernetes clouds in our jenkins
I'm trying to run cucumber tests via maven but as we do not expose services via alb in the apps-dev cluster I wanted to run the maven job as a pod on the apps-dev
cluster.
We've added pod label to the template but jenkins pipeline starts with just jnlp container.
pipeline {
agent {
kubernetes {
cloud 'apps-dev'
yamlFile '''
apiVersion: v1
kind: Pod
metadata:
labels:
jenkins/label: jenkins-apps-dev-agent
namespace: jenkins-jobs
containers:
- name: mavenjdk11
image: maven:3.8.2-adoptopenjdk-11
resources:
limits:
memory: "512Mi"
cpu: "500m"
requests:
memory: "256Mi"
cpu: "100m"
command:
- sleep
args:
- 99d
volumes:
- name: sharedvolume
emptyDir: {}
'''
}
}
...
and the logs
Created Pod: foo jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq
[Normal][jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq][LoggingEnabled] Successfully enabled logging for pod
Still waiting to schedule task
‘foo-foo-integration-foo-feature-tests-17-m-4hhpq’ is offline
[Normal][jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq][Scheduled] Successfully assigned jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq to fargate-ip-176-24-3-48.ec2.internal
[Normal][jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq][Pulling] Pulling image "jenkins/inbound-agent:4.3-4"
[Normal][jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq][TaintManagerEviction] Cancelling deletion of Pod jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq
[Normal][jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq][Pulled] Successfully pulled image "jenkins/inbound-agent:4.3-4" in 15.29095263s
[Normal][jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq][Created] Created container jnlp
[Normal][jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq][Started] Started container jnlp
Agent foo-foo-integration-foo-feature-tests-17-m-4hhpq is provisioned from template foo_foo-integration_foo-feature-tests_17-mnscq-lz8wj
---
apiVersion: "v1"
kind: "Pod"
metadata:
annotations:
buildUrl: "https://jenkins.cloud.bar.com/job/foo/job/foo-integration/job/foo-feature-tests/17/"
runUrl: "job/foo/job/foo-integration/job/foo-feature-tests/17/"
labels:
jenkins/label-digest: "baf69ff51703705e7e8252b6f5a54fc663dae21d"
jenkins/label: "foo_foo-integration_foo-feature-tests_17-mnscq"
name: "foo-foo-integration-foo-feature-tests-17-m-4hhpq"
spec:
containers:
- env:
- name: "JENKINS_SECRET"
value: "********"
- name: "JENKINS_AGENT_NAME"
value: "foo-foo-integration-foo-feature-tests-17-m-4hhpq"
- name: "JENKINS_WEB_SOCKET"
value: "true"
- name: "JENKINS_NAME"
value: "foo-foo-integration-foo-feature-tests-17-m-4hhpq"
- name: "JENKINS_AGENT_WORKDIR"
value: "/home/jenkins/agent"
- name: "JENKINS_URL"
value: "https://jenkins.cloud.bar.com/"
image: "jenkins/inbound-agent:4.3-4"
name: "jnlp"
resources:
limits: {}
requests:
memory: "256Mi"
cpu: "100m"
volumeMounts:
- mountPath: "/home/jenkins/agent"
name: "workspace-volume"
readOnly: false
nodeSelector:
kubernetes.io/os: "linux"
restartPolicy: "Never"
volumes:
- emptyDir:
medium: ""
name: "workspace-volume"
There's an error in my yaml, it should have been
apiVersion: v1
kind: Pod
metadata:
labels:
jenkins/label: jenkins-apps-dev-agent
namespace: jenkins-jobs
spec:
containers:
- name: mavenjdk11
image: maven:3.8.2-adoptopenjdk-11
resources:
limits:
memory: "512Mi"
cpu: "500m"
requests:
memory: "256Mi"
cpu: "100m"
command:
- sleep
args:
- 99d
volumes:
- name: sharedvolume
emptyDir: {}
the spec:
before containers was missing