Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-48421

Support kubernetes in Declarative Pipeline

XMLWordPrintable

      In scope

      • Define a pod for the pipeline with all the same directives as found in pod templates
      • When the Pipeline is run the pod is started on Kubernetes
      • When the Pipeline executes, the steps are run on the container specified in the agent container block
        • The container named in these blocks must be defined in the pod template. If it does not exist in the pod template, the pod should not be created and should result in an error.
      • Support top level and stage level agent directive.
      • Pod name is automatically generated by Jenkins
        • pod name is the full name of the Pipeline and its run ID e.g. pipeline/myproject/mypipeline/123
      • Pod is automatically labeled with the pipelineName and runId

      Out of scope

      • Anything else not outlined in this ticket
      • Loading the pod template from a YAML file (this can come later)

      Example

      pipeline {
        pod {
          containers {
            container {
              name 'database-testing'
              image 'mysql'
            }
            container {
              name 'build'
              image 'maven'
            }
            container {
              name 'deploy'
              image 'bash'
            }
          }
        }
        agent none
        stages {
          stage('build app') {
            agent {
              container { 
                name 'build' 
              } 
            }
            steps {
              sh 'mvn clean install'
              stash 'app' 'target/*.war'
            }
          }
          stage('build app') {
            agent {
              container { 
                name 'build' 
              } 
            }
            steps {
              unstash 'app'
              sh './deploy.sh'
            }
          }
        }
      }
      

            abayer Andrew Bayer
            jamesdumay James Dumay
            Votes:
            19 Vote for this issue
            Watchers:
            33 Start watching this issue

              Created:
              Updated:
              Resolved: