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

PostBuild declarative validator called twice

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • Parent POM 2.33
      Jenkins 2.7.3
      Declarative 1.2.2

      I am hoping to extend the Declarative Model Validator to provide linting services that have the team's policies / standards integrated. Working on a validator for ModelASTPostBuild I saw that the validator was being called twice.

       

      My extension:

      @Extension
      public class PostBuildValidator extends DeclarativeValidatorContributor {
      
          @CheckForNull
          @Override
          public String validateElement(@Nonnull ModelASTPostBuild postBuild, @CheckForNull FlowExecution execution) {
              return "abc" + postBuild.getName();
          }
      }
      

      My jenkinsfile:

      pipeline {
        agent {
          label 'unix'
        }
        stages {
          stage('test'){
            steps{
              echo "test"
            }
          }
        }
        post {
          always{
            echo "cleaning"
            deleteDir()
          }
        }
      }
      

      Response from pipeline-model-converter/validateJenkinsfile:

      {"status":"ok","data":{"result":"failure","errors":[

      {"error":["abcpost @ line 12, column 3.","abcpost @ line 12, column 3."]}

      ]}}

            abayer Andrew Bayer
            stevenfoster Steven Foster
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: