janjoerke / vscode-jenkins-pipeline-linter-connector

MIT License
60 stars 21 forks source link

Random comma character in validated Jenkinsfile #41

Open mippos opened 3 years ago

mippos commented 3 years ago

Thanks for the excellent plugin! I am using the plugin pretty much daily.

There is one issue that I am seeing frequently. I don't know is this caused by the plugin or does this come from Jenkins side.

Problem is that when validating, there comes some extra comma to the file sometimes. The extra character is always a comma. When I rerun validation again for the same Jenkinsfile, it passes.

Example error:

Errors encountered validating Jenkinsfile:
WorkflowScript: 210: unexpected token: , @ line 210, column 20.
                      ,             }
                      ^

I would say this problem comes roughly every 10th time. The problem has been coming longer with multiple Jenkisfiles and character location is always random. It has been at least with ~3 Jenkins versions. Jenkins server is located on same network with ~1ms latency.

Any idea what can cause this extra comma issue?

richardg93 commented 3 years ago

I also see this issue - appears to be at random. Not a gamechanger as you can just run again. Love the plug in!!

PostImpatica commented 2 years ago

The extension doesn't work at all for me if I create it in Visual Studio 2022. It creates it as a UTF-8 BOM file.

I get the following error:

Errors encountered validating Jenkinsfile:
WorkflowScript: 1: unexpected char: 0xBB @ line 1, column 2.
   pipeline {
    ^

Easy fix though. In Visual Studio, click File -> Save As and remove the asterisk on the end of the file name and click the little dropdown triangle on the save button and choose to save with encoding. Choose Unicode(UTF-8 unsigned...).

sfmacrae commented 1 year ago

Using jenkins 2.363 Plugin version v1.2.0 The plugin concept is really good. In my case, the error occurs most of the time (90%) and subsequent validations always fail. I am happy to try a debug version of the plugin to help debug the issue.

WorkflowScript: 1494: unexpected token: , @ line 1494, column 11. , env.TEST_CHANGELIST_NUMBER = convertP4LabelToCl(env.TEST_CHANGELIST_NUMBER) ^

The groovy code looks like:

               if (env.BRANCH_BASELINE_LABEL.isNumber() == false) {
                    env.BRANCH_BASELINE_LABEL = convertP4LabelToCl(env.BRANCH_BASELINE_LABEL)
                }

                if (g_isCompare == true && env.TEST_CHANGELIST_NUMBER.isNumber() == false) {
                    env.TEST_CHANGELIST_NUMBER = convertP4LabelToCl(env.TEST_CHANGELIST_NUMBER)  // line 1494
                }

Another example error is:

Errors encountered validating Jenkinsfile: WorkflowScript: 2815: unexpected token: AGENT_LABE @ line 2815, column 1. AGENT_LABE,L="" ^

The groovy code looks like:

// This is set according to input parameter MPD_ENVIRO AGENT_LABEL="" // line 2815

julioarturo commented 9 months ago

The extension doesn't work at all for me if I create it in Visual Studio 2022. It creates it as a UTF-8 BOM file.

I get the following error:

Errors encountered validating Jenkinsfile:
WorkflowScript: 1: unexpected char: 0xBB @ line 1, column 2.
   pipeline {
    ^

Easy fix though. In Visual Studio, click File -> Save As and remove the asterisk on the end of the file name and click the little dropdown triangle on the save button and choose to save with encoding. Choose Unicode(UTF-8 unsigned...).

Yes, the file save as UTF-signeed, that's wrong, thank you!

rustyhowell commented 1 month ago

I see the same issue with Linux x64 6.10 (Fedora) VSCode 1.94.2 Jenkins Pipelne Linter Connector v1.2.0

I have made sure that my file is UTF-8 but I still get the same error. A funny thing though is that if I comment out the offending line of code, it will pass. But if I remove the commented out line, another similar error pops up on the next line.

I have looked at hexdump to ensure there were no hidden non-printable chars in there anywhere. And if I just use curl to POST the Jenkinsfile to my linter, it always succeeds.