Jenkinsfile - No such DSL method 'properties' found among steps

6/1/2018

The Jenkinsfile similar to the one below works fine for me without properties section. But when I add properties Jenkins job fails with

java.lang.NoSuchMethodError: No such DSL method 'properties' found among steps [archive, bat, build, catchError, checkout, container, containerLog, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, echo, error, .....

I've tried to place it in the root section too, but with the same result. So, I'm not sure where to put it now.

Jenkinsfile

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

podTemplate(label: label, containers: [
  containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.8', command: 'cat', ttyEnabled: true)
],
volumes: [
]) {
  node(label) {
    properties(
      [
        [
          $class  : 'jenkins.model.BuildDiscarderProperty',
          strategy: [
            $class: 'LogRotator',
            numToKeepStr: '50'
          ]
        ],
        pipelineTriggers(
          [
            [
              $class: 'hudson.triggers.TimerTrigger',
              spec  : "*/5 * * * *"
            ]
          ]
        )
      ]
    )

    stage('Run kubectl') {
      container('kubectl') {
        withEnv([
            "ES_URL=elasticsearch.storage:9200"
        ]){
            sh """
               kubectl run -it --rm=true busybox-curl --image=yauritux/busybox-curl --restart=Never -- curl "$ES_URL"
            """
      }
    }
  }
}

Jenkins is running on Kubernetes. To set up Jenkins I used stable/jenkins helm chart.

Thank you!

-- cyrillk
jenkins
jenkins-pipeline
kubernetes

1 Answer

6/7/2018

Ok, I've figured out the problem. Some of the plugins were not updated and apparently caused some conflicts. I updated all the plugins and the problem has gone.

-- cyrillk
Source: StackOverflow