简体   繁体   中英

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

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM