[JIRA] (JENKINS-59378) Scripted Pipeline linting works from CLI but not from Api

3 views
Skip to first unread message

marcos@unitron.com.br (JIRA)

unread,
Sep 15, 2019, 12:07:03 AM9/15/19
to jenkinsc...@googlegroups.com
Marcos Diez created an issue
 
Jenkins / Bug JENKINS-59378
Scripted Pipeline linting works from CLI but not from Api
Issue Type: Bug Bug
Assignee: Unassigned
Components: pipeline
Created: 2019-09-15 04:06
Environment: Jenkins ver. 2.176.3, Ubuntu 18.04
authentication-tokens Authentication Tokens API Plugin 1.3
pipeline-build-step Pipeline: Build Step 2.9
credentials-binding Credentials Binding Plugin 1.20
jdk-tool Oracle Java SE Development Kit Installer Plugin 1.3
build-name-setter Build Name and Description Setter 2.0.3
mailer Mailer Plugin 1.27
antisamy-markup-formatter OWASP Markup Formatter Plugin 1.6
workflow-scm-step Pipeline: SCM Step 2.9
junit JUnit Plugin 1.28
ssh-slaves SSH Slaves plugin 1.30.2
pipeline-milestone-step Pipeline: Milestone Step 1.3.1
handlebars JavaScript GUI Lib: Handlebars bundle plugin 1.1.1
workflow-basic-steps Pipeline: Basic Steps 2.18
token-macro Token Macro Plugin 2.8
console-badge Console Badge 1.1
pipeline-stage-view Pipeline: Stage View Plugin 2.12
pipeline-stage-tags-metadata Pipeline: Stage Tags Metadata 1.3.9
pipeline-stage-step Pipeline: Stage Step 2.3
git-server GIT server Plugin 1.8
workflow-multibranch Pipeline: Multibranch 2.21
pipeline-rest-api Pipeline: REST API Plugin 2.12
command-launcher Command Agent Launcher Plugin 1.3
git-client Git client plugin 2.8.6
jsch JSch dependency plugin 0.1.55.1
jquery-detached JavaScript GUI Lib: jQuery bundles (jQuery and jQuery UI) plugin 1.2.1
bouncycastle-api bouncycastle API Plugin 2.17
workflow-support Pipeline: Supporting APIs 3.3
lockable-resources Lockable Resources plugin 2.5
apache-httpcomponents-client-4-api Apache HttpComponents Client 4.x API Plugin 4.5.10-1.0
cloudbees-folder Folders Plugin 6.9
pipeline-model-api Pipeline: Model API 1.3.9
ssh-credentials SSH Credentials Plugin 1.17.2
build-user-vars-plugin user build vars plugin 1.5
workflow-api Pipeline: API 2.37
momentjs JavaScript GUI Lib: Moment.js bundle plugin 1.1.1
pipeline-input-step Pipeline: Input Step 2.11
workflow-step-api Pipeline: Step API 2.20
workflow-aggregator Pipeline 2.6
display-url-api Display URL API 2.3.2
pipeline-graph-analysis Pipeline Graph Analysis Plugin 1.10
credentials Credentials Plugin 2.3.0
build-timestamp Build Timestamp Plugin 1.0.3
ace-editor JavaScript GUI Lib: ACE Editor bundle plugin 1.1
workflow-durable-task-step Pipeline: Nodes and Processes 2.34
branch-api Branch API Plugin 2.5.4
scm-api SCM API Plugin 2.6.3
structs Structs Plugin 1.20
durable-task Durable Task Plugin 1.30
git Git plugin 3.12.1
jaxb JAXB plugin 2.3.0.1
pipeline-model-declarative-agent Pipeline: Declarative Agent API 1.1.1
workflow-job Pipeline: Job 2.35
build-with-parameters Build With Parameters 1.4
jackson2-api Jackson 2 API Plugin 2.9.9.1
workflow-cps Pipeline: Groovy 2.74
rebuild Rebuilder 1.31
workflow-cps-global-lib Pipeline: Shared Groovy Libraries 2.15
matrix-project Matrix Project Plugin 1.14
docker-workflow Docker Pipeline 1.19
pipeline-model-definition Pipeline: Declarative 1.3.9
pipeline-model-extensions Pipeline: Declarative Extension Points API 1.3.9
script-security Script Security Plugin 1.64
plain-credentials Plain Credentials Plugin 1.5
docker-commons Docker Commons Plugin 1.15

Labels: pipeline plugin
Priority: Minor Minor
Reporter: Marcos Diez

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!

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

jnuno.costa@gmail.com (JIRA)

unread,
Dec 19, 2019, 6:53:02 AM12/19/19
to jenkinsc...@googlegroups.com
José Costa commented on Bug JENKINS-59378
 
Re: Scripted Pipeline linting works from CLI but not from Api

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

danieltaub7@gmail.com (JIRA)

unread,
Mar 27, 2020, 5:46:03 PM3/27/20
to jenkinsc...@googlegroups.com

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

This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

danieltaub7@gmail.com (JIRA)

unread,
Mar 27, 2020, 6:54:03 PM3/27/20
to jenkinsc...@googlegroups.com
daniel taub updated an issue
 
Change By: daniel taub
Component/s: pipeline-model-definition-plugin
Reply all
Reply to author
Forward
0 new messages