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

Replace Declarative Docker agent directive with new implementation

    XMLWordPrintable

Details

    • Declarative - 1.2, Pipeline - December, Pipeline - April 2018

    Description

      Goals

      • We want to have a new implementation for running steps inside a Docker container that is transparent to the Pipeline author
      • We want to ensure that as this developed that we start making changes that allow us to swap out the implementation in the future (e.g. docker, k8, etc)
      • We want customers to try this new implementation without having to use patched plugins or special builds from a branch

      Scope

      • Declarative Docker agent directive can be used to run steps for a stage or for the whole pipeline
      • The new implementation can be enabled by specifying Pipeline->Options->dockerPipelineVersion = 2
      • Must be able to use an off the shelf docker container without modifying it so it works with Jenkins
      • Honour the entry point of the container
      • Sharing the workspace from the top level agent to a per stage Docker agent (and back again!)

      Out of scope

      • Declarative Docker agent directive that specifies a Dockerfile
      • Scripted docker.inside
      • Scripted docker.build
      • Building containers
      • Linked containers
      • Caching directories

      Acceptance criteria
      The following steps should work using the new implementation (even if modifications are needed to these steps):

      • withMaven()
      • dir()
      • withCredentials

      The following functionality should work:

      • Tool installers
      • Config File Provider

      Examples
      Per stage

      pipeline {
        options {
          dockerPipelineVersion(2)
        }
        agent none // Will not reuse workspace
        stages {
           stage (‘build’) {
              agent { docker ‘maven3’ } 
              steps { 
      	   sh ‘mvn clean test’
              } 
           }
        }
      }
      

      Whole Pipeline

      pipeline {
        options {
          dockerPipelineVersion(2)
        }
        agent { docker ‘maven3’ } // will reuse workspace for all stages unless specified
        stages {
           stage (‘build’) {
              steps { 
      	   sh ‘mvn clean test’
              } 
           }
        }
      }
      

      Attachments

        Issue Links

          Activity

            Code changed in jenkins
            User: Nicolas De Loof
            Path:
            pom.xml
            src/main/groovy/io/jenkins/docker/pipeline/DockerAgentScript.groovy
            src/main/java/io/jenkins/docker/pipeline/DockerAgent.java
            http://jenkins-ci.org/commit/docker-plugin/65dce18da936fbeea34d89245595d085866dd725
            Log:
            JENKINS-48050 declarative « container » agent

            Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: pom.xml src/main/groovy/io/jenkins/docker/pipeline/DockerAgentScript.groovy src/main/java/io/jenkins/docker/pipeline/DockerAgent.java http://jenkins-ci.org/commit/docker-plugin/65dce18da936fbeea34d89245595d085866dd725 Log: JENKINS-48050 declarative « container » agent Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>

            Code changed in jenkins
            User: Nicolas De Loof
            Path:
            pom.xml
            src/main/groovy/io/jenkins/docker/pipeline/DockerAgentScript.groovy
            src/main/java/io/jenkins/docker/pipeline/DockerAgent.java
            http://jenkins-ci.org/commit/docker-plugin/2e2c79fc3aba672e6a19d812d47ac55b2c7a418b
            Log:
            JENKINS-48050 declarative « container » agent

            Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: pom.xml src/main/groovy/io/jenkins/docker/pipeline/DockerAgentScript.groovy src/main/java/io/jenkins/docker/pipeline/DockerAgent.java http://jenkins-ci.org/commit/docker-plugin/2e2c79fc3aba672e6a19d812d47ac55b2c7a418b Log: JENKINS-48050 declarative « container » agent Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>

            Code changed in jenkins
            User: Nicolas De Loof
            Path:
            pom.xml
            src/main/groovy/io/jenkins/docker/pipeline/DockerAgentScript.groovy
            src/main/java/io/jenkins/docker/pipeline/DockerAgent.java
            http://jenkins-ci.org/commit/docker-plugin/3cea7e1a5c49d069be4aeea1b027210101ce4bac
            Log:
            JENKINS-48050 declarative « container » agent

            Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: pom.xml src/main/groovy/io/jenkins/docker/pipeline/DockerAgentScript.groovy src/main/java/io/jenkins/docker/pipeline/DockerAgent.java http://jenkins-ci.org/commit/docker-plugin/3cea7e1a5c49d069be4aeea1b027210101ce4bac Log: JENKINS-48050 declarative « container » agent Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
            jglick Jesse Glick added a comment -

            Alternate simpler approach: docker PR 681

            jglick Jesse Glick added a comment - Alternate simpler approach: docker PR 681
            bitwiseman Liam Newman added a comment -
            bitwiseman Liam Newman added a comment - I've added a link to some work done for this https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/255

            People

              Unassigned Unassigned
              jamesdumay James Dumay
              Votes:
              14 Vote for this issue
              Watchers:
              41 Start watching this issue

              Dates

                Created:
                Updated: