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

Using post section in kuberenetes agents (kuberenetes-plugin)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • kubernetes-plugin
    • None

      Kubernetes-plugin claims to have integration with declarative pipeline.

      however, picking up the example on the github repo:

      pipeline {
        agent {
          kubernetes {
            yamlFile 'examples/declarative_from_yaml_file/KubernetesPod.yaml'
          }
        }
        stages {
          stage('Run maven') {
            steps {
              sh 'set'
              sh "echo OUTSIDE_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}"
              container('maven') {
                sh 'echo MAVEN_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}'
                sh 'mvn -version'
              }
              container('busybox') {
                sh 'echo BUSYBOX_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}'
                sh '/bin/busybox'
              }
            }
          }
        }
      }
      // simply adding a basic post step
      post{
        always{
          sh "echo this is a post step"
        }
      }

      adding the simple post section will not work with the error:

      java.lang.NoSuchMethodError: No such DSL method 'post' found among steps
      

      Analyzing the job logs I see that while it "supports" declarative syntax there is a node call on the run start.

      So from what I believe declarative pipeline is not supported, what is supported is steps declarative syntax.

      This should be clear in the docs, there is no real mention of this anywhere official 

       

       

            Unassigned Unassigned
            one_random_dev Random Dev
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: