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

Cannot mix dockerfile and non docker agents in a pipeline

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • pipeline
    • None
    • Jenkins version 2.149 running on CentOS7, slaves are CentOS7 machines.

      I have a pipeline with multiple stages that all run on a single label of a slave inside a docker container using a dockerfile directive, if I add a stage that has a different label and using a node directive for that specific stage then the stage fails with the following error.

      13:14:23 [feature_VPC-795-e2e-develop-EF452P7T7LHQ5EOUGZMAVASZUDQBHZAET7G7APUGZSFQCS7RE5TQ] Running shell script
      13:14:23 unknown flag: --workdir
      13:14:23 See 'docker exec --help'.
      
       
      

      This works fine

      // start of pipeline
      pipeline {
        triggers {
          pollSCM '0 0 * * 0'
        }
            agent { 
              node { 
                label 'docker-slave' 
              } 
            }  options {
          timestamps()
          disableConcurrentBuilds()
        }  environment {
      
          CI = 'true'
        }  stages {
          stage('test old slave') {
            steps {
              sh "date"     
            }
          }    
          stage('test new slave') {
            agent { 
              node { 
                label 'non-docker-slave' 
              } 
            }
            steps {
              sh "date"
            } // steps
          } // stage
        } //stages
      } // pipeline

      This does not work

      // start of pipeline
      pipeline {
        triggers {
          pollSCM '0 0 * * 0'
        }
        agent {
          dockerfile {
            label 'docker-slave'
            filename 'Dockerfile'
            }
        }  options {
          timestamps()
          disableConcurrentBuilds()
        }  environment { 
          CI = 'true'
        }  stages {
          stage('test old slave') {
            steps {
              sh "date"     
            }
          }    
          stage('test new slave') {
            agent { 
              node { 
                label 'non-docker-slave' 
              } 
            }
            steps {
              sh "date"
            } // steps
          } // stage
        } //stages
      } // pipeline

            Unassigned Unassigned
            gleb_zverinskiy Gleb Zverinskiy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: