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

PodTemplate is now mandatory within pipeline

    XMLWordPrintable

Details

    Description

      Before version 0.11
      We were able to declare in the global jenkins configuration a PodTemplate with containers.

      Here an simple pipeline example that was working with a global PodTemplate with 0.10

      stage("Example"){
            node("mypod"){
                container("golang"){
                sh '''
                  echo "something"
                '''
              }
           }
      }
      

      With 0.11 we get an error:

      org.jenkinsci.plugins.workflow.steps.MissingContextVariableException: Required context class org.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateStep is missing
      

      It is now (with 0.11) mandatory to have the PodTemplate and containers declare within the pipeline to be able to make the Ā«containerĀ» step work again.

      Attachments

        Activity

          pascallap Pascal Laporte created issue -
          csanchez Carlos Sanchez made changes -
          Field Original Value New Value
          Status Open [ 1 ] In Progress [ 3 ]

          I am seeing this issue too, with globally configured PodTemplates. As a workaround, I have modified my pipelines like this:

          // Before 0.11, using a global PodTemplate named "mypod":
          node("mypod") {
            stage("Build") {
              container("code-builder") {
                // build steps elided
              }
            }
          }

          With the upgrade to 0.11, add a podTemplate declaration to the top, referencing the global PodTemplate:

          // Using 0.11, global PodTemplate named "mypod":
          podTemplate(name: "mypod") {
            node("mypod") {
              stage("Build") {
                container("code-builder") {
                  // build steps elided
                }
              }
            }
          }

          It's unfortunate that 0.11 introduces a breaking API change.

          tjdziuba Theodore Dziuba added a comment - I am seeing this issue too, with globally configured PodTemplates. As a workaround, I have modified my pipelines like this: // Before 0.11, using a global PodTemplate named "mypod" : node( "mypod" ) { stage( "Build" ) { container( "code-builder" ) { // build steps elided } } } With the upgrade to 0.11, add a podTemplate declaration to the top, referencing the global PodTemplate: // Using 0.11, global PodTemplate named "mypod" : podTemplate(name: "mypod" ) { node( "mypod" ) { stage( "Build" ) { container( "code-builder" ) { // build steps elided } } } } It's unfortunate that 0.11 introduces a breaking API change.
          csanchez Carlos Sanchez added a comment - Fixed in https://github.com/jenkinsci/kubernetes-plugin/pull/148
          csanchez Carlos Sanchez made changes -
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Closed [ 6 ]

          Awesome, thank you Carlos! You work on the k8s plugin has streamlined and simplified a lot of things for my company, and for others I'm sure.

          tjdziuba Theodore Dziuba added a comment - Awesome, thank you Carlos! You work on the k8s plugin has streamlined and simplified a lot of things for my company, and for others I'm sure.
          tracedeng trace deng made changes -
          Comment [ I also encountered this problem, and follow this operation
          {code:java}
          // Using 0.11, global PodTemplate named "mypod":
          podTemplate(name: "mypod") {
            node("mypod") {
              stage("Build") {
                container("code-builder") {
                  // build steps elided
                }
              }
            }
          }{code}
          result like
          {code:java}
          // code placeholder
          [Pipeline] podTemplate
          [Pipeline] // podTemplate
          [Pipeline] End of Pipeline
          ERROR: Cloud does not exist: kubernetes
          Finished: FAILURE
          {code}
          I use kubernetes plugin 0.11,  when can you upgrade kubernets plugins?

            ]

          People

            csanchez Carlos Sanchez
            pascallap Pascal Laporte
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: