[kubernetes-plugin] Define pod with yaml

185 views
Skip to first unread message

Ram Kamath

unread,
Apr 26, 2018, 4:42:24 AM4/26/18
to Jenkins Users
Dear Jenkins Users,

I am trying to make use of the pod creation with yaml feature introduced in V1.6. I am using the example pipeline on the GitHub page [HERE]. I always get an exception. Could anybody shed some light on my possible mistake?

my jenkinsfile is 
pipeline {
  agent {
    kubernetes {
      label 'mypod'
      defaultContainer: 'jnlp'
      yaml """
apiVersion: v1
kind: Pod
metadata:
  labels:
    app: test
spec:
  containers:
  - name: maven
    image: maven:alpine
    command:
    - cat
    tty: true
  - name: busybox
    image: busybox
    command:
    - cat
    tty: true
"""
    }
  }
  stages {
    stage('Run maven') {
      steps {
        container('maven') {
          sh 'mvn -version'
        }
        container('busybox') {
          sh '/bin/busybox'
        }
      }
    }
  }
}

And the exception is

Obtained Jenkinsfile from 890534edc3963a758f650fb2a5d0bcea77869b86
Running in Durability level: MAX_SURVIVABILITY
org
.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 3: Expected to find someKey "someValue" @ line 3, column 16.
       kubernetes
{
                 
^

1 error

        at org
.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
        at org
.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085)
        at org
.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
        at org
.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
        at org
.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
        at groovy
.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
        at groovy
.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
        at groovy
.lang.GroovyShell.parseClass(GroovyShell.java:688)
        at groovy
.lang.GroovyShell.parse(GroovyShell.java:700)
        at org
.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:133)
        at org
.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
        at org
.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:559)
        at org
.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:520)
        at org
.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:323)
        at hudson
.model.ResourceController.execute(ResourceController.java:97)
        at hudson
.model.Executor.run(Executor.java:429)
Finished: FAILURE

I am using plugin version 1.6 and Jenkins 2.107.2

Carlos Sanchez

unread,
Apr 26, 2018, 5:17:58 AM4/26/18
to Jenkins Users
there's a typo in the example 
defaultContainer: 'jnlp'
should be
defaultContainer 'jnlp'

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3b15c9ce-1b35-4171-9ab1-63a0286e1867%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ram Kamath

unread,
Apr 26, 2018, 5:49:59 AM4/26/18
to Jenkins Users
Thanks. This fixed the issue. 
Reply all
Reply to author
Forward
0 new messages