这是我的声明性 Jenkinsfile 的一个子集:
pipeline {
agent {
kubernetes {
yamlFile 'pod.yml'
defaultContainer 'tools'
}
}
stages {
stage('Init') { // <- this stage executes in Kubernetes and works very well
steps {
sh "echo init"
}
}
stage('Build') {
agent { label 'B202981' } // <- This wont work; B202981 is computer on my network
steps {
sh "echo build"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
当此管道运行时,它会因异常而失败,您可以在此处看到该异常,而谷歌搜索此异常对我没有帮助。
java.lang.ClassCastException: hudson.slaves.DumbSlave cannot be cast to org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave
at org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator$1.launch(ContainerExecDecorator.java:250)
at hudson.Launcher$ProcStarter.start(Launcher.java:455)
at org.jenkinsci.plugins.durabletask.WindowsBatchScript.doLaunch(WindowsBatchScript.java:83)
at org.jenkinsci.plugins.durabletask.FileMonitoringTask.launchWithCookie(FileMonitoringTask.java:106) …Run Code Online (Sandbox Code Playgroud) jenkins jenkins-declarative-pipeline kubernetes-jenkins-plugin