podTemplate(containers: [ containerTemplate( name: 'gradle', image: 'gradle:7.6.0-jdk11', command: 'sleep', args: '30d' ) ]) { node(POD_LABEL) { stage('Get a Gradle project') { container('gradle') { stage('Build a Gradle project') { sh ''' echo "gradle build" ''' } } } } } pipeline { agent { kubernetes { yaml ''' apiVersion: v1 kind: Pod metadata: labels: some-label: some-label-value spec: containers: - name: gradle image: gradle:7.6.0-jdk11 tty: true ''' retries 2 } } stages { stage('Run gradle') { steps { container('gradle') { sh './gradlew clean build' } } } } }