How do i put a image definition in a Kubernetes pod template and refer to it in a pipeline job

Currently I have successfully installed Cloudbees CI on OpenShift 4.5. One thing that i would like to do is make it so that developers do not have to indicate whole yaml templates for the pods that are being used. For example, i would want a developer to only have to indicate maven in the pipeline job within stages to run maven on that container. What would that look like with the following parameters?


pipeline {

  agent {

    kubernetes {

      idleMinutes 10

      yaml """


apiVersion: v1

kind: Pod


  containers:  # list of containers that you want present for your build, you can define a default container in the Jenkinsfile

    - name: maven

      image: maven:3.5.4-jdk-8-slim

      command: ["tail", "-f", "/dev/null"]  # this or any command that is basically a noop is required, this is so that you don't overwrite the entrypoint of the base container

      imagePullPolicy: Always # use cache or pull image for agent

      resources:  # limits the resources your build container


          memory: "1Gi"

          cpu: "1m"


          memory: "1Gi"


    defaultContainer "maven"



  stages {

    stage('Run Hello World') {

      steps {

        container('maven') {

            sh 'echo "hello world"'







Please sign in to leave a comment.