I was using kuberntes-plugin. In its README it has given how to write scripted pipeline with multiple container images, like
podTemplate(label: 'mypod', containers: [
containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'golang', image: 'golang:1.8.0', ttyEnabled: true, command: 'cat')
]) {
node('mypod') {
I tried the following for declarative pipeline.
pipeline {
agent {
kubernetes {
//cloud 'kubernetes'
label 'mypod'
containerTemplate {
name 'maven'
image 'maven:3.3.9-jdk-8-alpine'
ttyEnabled true
command 'cat'
}
containerTemplate {
name 'containtertwo'
image 'someimage'
ttyEnabled true
}
}
}
It creates a pod with only one container.
how to use multiple containerTemplates with declarative pipeline?