Hi, I am using the Jenkins for Kubernetes plugin, and in the documentation I saw the following to implement retries:
pipeline {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
metadata:
labels:
some-label: some-label-value
spec:
containers:
- name: maven
image: maven:alpine
imagePullPolicy: always
command:
- cat
tty: true
- name: busybox
image: busybox
command:
- cat
tty: true
'''
retries 2
}
}
stages {
stage('Run maven') {
steps {
container('maven') {
sh 'mvn -version'
}
container('busybox') {
sh '/bin/busybox'
}
}
}
}
}
However, it also does a retry if the stage has an issue (not a exit 1 from the sh) e.g. pod loss during the shell execution. I would like to only do the retry if there is an issue with the pod initialization e.g. if the image pull for the maven image fails. Is there a way to achieve this i.e. retry only the agent initialization and not the stages themselves?