Reputation: 31
The declarative pipeline by defining yaml inside the kuberentes section of agent is not working. I was using jenkins 2.176.x LTS version. I am getting the following error in the console "ERROR: Node is not a Kubernetes node:"
I have tried all the existing solutions available in stack overflow.
Please find the pipeline code:
pipeline {
agent {
kubernetes {
//cloud 'kubernetes'
yaml """
apiVersion: v1
kind: Pod
spec:
containers:
- name: maven
image: maven:3.3.9-jdk-8-alpine
command: ['cat']
tty: true
"""
}
}
stages {
stage('Run maven') {
steps {
container('maven') {
sh 'mvn -version'
}
}
}
}
}
It should deploy the pod and run the command
Upvotes: 3
Views: 1508
Reputation: 156
You must supply a label to the kubernetes block:
kubernetes {
label 'mylabel'
yaml """
....
}
Upvotes: 1