janjoerke / vscode-jenkins-pipeline-linter-connector

MIT License
60 stars 21 forks source link

Random comma character in validated Jenkinsfile #41

Open mippos opened 2 years ago

mippos commented 2 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 2 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 1 year 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 6 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!