Slave from podTemplate does not deploy pod

10/4/2019

I am trying to start a Jenkins Slave using podTemplate but all it does is hang on in Jenkins:

Still waiting to schedule task
Waiting for next available executor

I created a function for my podTemplates (including JNLP) as outlined here:

package com.test.utils.PodTemplates

 public void jnlpTemplate(body) {
     podTemplate(
         containers: [containerTemplate(name: 'jnlp', image: 'jenkinsci/jnlp-slave:3.10-1-alpine', args: '${computer.jnlpmac} ${computer.name}')]) {
     body.call()
     }
}

public void dockerTemplate(body) {
...
}

return this

My Jenkinsfile has:

import com.test.utils.PodTemplates

label = "jenkins-${UUID.randomUUID().toString()}"

slaveTemplates = new PodTemplates()

slaveTemplates.jnlpTemplate {
    node(label) {
        stage('Run shell') {
            sh 'echo hello world'
        }
    }
}

Expected to launch a new Jenkins Slave but it just hangs and never deploys a slave pod.

If change Jenkinsfile to:

import com.test.utils.PodTemplates

label = "worker-${UUID.randomUUID().toString()}"

podTemplate(label: label, 
    containers: [containerTemplate(name: 'jnlp', 
                                    image: 'jenkinsci/jnlp-slave:3.10-1-alpine', 
                                    args: '${computer.jnlpmac} ${computer.name}')]) 
{
slaveTemplates = new PodTemplates()

slaveTemplates.jnlpTemplate {
    node(label) {
        stage('Run shell') {
            sh 'echo hello world'
        }
    }
  }
}

It deploys the pod and succeeds echoing hello world.

-- Squirrel
jenkins
jenkins-groovy
jenkins-pipeline
kubernetes

0 Answers