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

Scripted Pipeline linting works from CLI but not from Api

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Labels:
    • Environment:
    • Similar Issues:

      Description

      According to https://jenkins.io/doc/book/pipeline/development/#linter ,

      one can check the syntax of a Jenkinsfile either using the CLI

       

      java-jar jenkins-cli.jar declarative-linter < Jenkinsfile 
      

       

      or using the HTTP API:

       

      curl -X POST -F "jenkinsfile=<Jenkinsfile" $JENKINS_URL/pipeline-model-converter/validate

      Interestingly, though, the former (CLI) validates successfully Scripted Pipelines while the latter (HTTP) does not.

      Here is a trivial example of a Jenkinsfile:

      node {
        pwd
      }
      

      The CLI output is

      Jenkinsfile successfully validated.

      while the HTTP api output is

      Jenkinsfile content 'node {\n  pwd\n}\n' did not contain the 'pipeline' step

      I believe it's very convenient that the CLI can check Scripted Pipelines as well and it would be great if one could do it via the HTTP api as well!

       

        Attachments

          Activity

          Hide
          jncevcosta José Costa added a comment -

           I'm facing the same problem. I hope that HTTP API can lint the scripted jenkins file soon.

          Show
          jncevcosta José Costa added a comment -  I'm facing the same problem. I hope that HTTP API can lint the scripted jenkins file soon.
          Hide
          danieltaub daniel taub added a comment -

          Same for me, but i've noticed that the 

          java-jar jenkins-cli.jar declarative-linter < Jenkinsfile 
          

          returns Jenkinsfile successfully validated even if the scripted pipeline is having syntax errors,

          I hope they will fix the bug

          Show
          danieltaub daniel taub added a comment - Same for me, but i've noticed that the  java-jar jenkins-cli.jar declarative-linter < Jenkinsfile returns Jenkinsfile successfully validated even if the scripted pipeline is having syntax errors, I hope they will fix the bug

            People

            • Assignee:
              Unassigned
              Reporter:
              marcosdiez Marcos Diez
            • Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: