We used to have jobs defined like follow to reuse pods across job executions:
pipeline {
agent {
kubernetes {
cloud 'kubernetes'
idleMinutes 10
label "testjob"
defaultContainer 'fedora'
yaml '''
spec:
containers:
- name: fedora
image: 'registry.fedoraproject.org/fedora-minimal:latest'
command: [ 'sleep', 'infinity' ]
'''
}
}
stages {
stage("Run Test") {
steps {
sh 'echo yes'
}
}
}
}
With both idleMinutes
and label
are present, the job can be executed in the same pod without booting up a new one, the reason for us to execute the job on same pod is our job can be triggered very frequently, booting up a new pod for each build can be time and resource consuming and almost unacceptable for us.
Now I see there is a message says:
[WARNING] label option is deprecated. To use a static pod template, use the 'inheritFrom' option.
However I don’t find a solution to achieve the same goal without the “label” option, could someone help on how I can do that without the deprecated label
option?