jenkinsci / violation-comments-to-github-plugin

Comments GitHub pull requests with static code analyzer findings.
https://plugins.jenkins.io/violation-comments-to-github
MIT License
25 stars 18 forks source link

Step does not take a single required parameter - use named parameters instead #40

Closed mkrauser closed 2 years ago

mkrauser commented 2 years ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.332 OS: Linux - 4.19.0-18-cloud-amd64 --- ace-editor:1.1 analysis-model-api:10.9.2 antisamy-markup-formatter:2.7 apache-httpcomponents-client-4-api:4.5.13-1.0 authentication-tokens:1.4 blueocean:1.25.2 blueocean-autofavorite:1.2.5 blueocean-bitbucket-pipeline:1.25.2 blueocean-commons:1.25.2 blueocean-config:1.25.2 blueocean-core-js:1.25.2 blueocean-dashboard:1.25.2 blueocean-display-url:2.4.1 blueocean-events:1.25.2 blueocean-git-pipeline:1.25.2 blueocean-github-pipeline:1.25.2 blueocean-i18n:1.25.2 blueocean-jwt:1.25.2 blueocean-personalization:1.25.2 blueocean-pipeline-api-impl:1.25.2 blueocean-pipeline-editor:1.25.2 blueocean-pipeline-scm-api:1.25.2 blueocean-rest:1.25.2 blueocean-rest-impl:1.25.2 blueocean-web:1.25.2 bootstrap4-api:4.6.0-3 bootstrap5-api:5.1.3-4 bouncycastle-api:2.25 branch-api:2.7.0 build-timeout:1.20 caffeine-api:2.9.2-29.v717aac953ff3 checks-api:1.7.2 chucknorris:1.4 cloudbees-bitbucket-branch-source:751.vda_24678a_f781 cloudbees-folder:6.17 clover:4.12.1 cobertura:1.17 code-coverage-api:2.0.4 command-launcher:1.6 config-file-provider:3.9.0 content-replace:1.7.0 credentials:1074.v60e6c29b_b_44b_ credentials-binding:1.27.1 data-tables-api:1.11.3-6 display-url-api:2.3.5 docker-commons:1.19 docker-workflow:1.28 dtkit-api:3.0.0 durable-task:493.v195aefbb0ff2 echarts-api:5.2.2-2 email-ext:2.87 envinject:2.4.0 envinject-api:1.8 favorite:2.3.3 file-operations:1.11 font-awesome-api:5.15.4-5 forensics-api:1.7.0 generic-webhook-trigger:1.83 git:4.10.3 git-client:3.11.0 git-server:1.10 github:1.34.1 github-api:1.301-378.v9807bd746da5 github-autostatus:3.6.2 github-branch-source:2.11.4 github-checks:1.0.16 groovy:2.4 handlebars:3.0.8 handy-uri-templates-2-api:2.1.8-1.0 htmlpublisher:1.29 http_request:1.14 jackson2-api:2.13.1-246.va8a9f3eaf46a jacoco:3.3.1 javax-activation-api:1.2.0-2 javax-mail-api:1.6.2-5 jaxb:2.3.0.1 jdk-tool:1.5 jenkins-design-language:1.25.2 jira-steps:1.6.0 jjwt-api:0.11.2-9.c8b45b8bb173 job-dsl:1.78.3 jquery-detached:1.2.1 jquery3-api:3.6.0-2 jsch:0.1.55.2 junit:1.55 lockable-resources:2.14 mailer:408.vd726a_1130320 matrix-auth:3.0.1 matrix-project:1.20 mercurial:2.16 momentjs:1.1.1 okhttp-api:4.9.3-105.vb96869f8ac3a pipeline-build-step:2.15 pipeline-graph-analysis:188.v3a01e7973f2c pipeline-input-step:446.vf27b_0b_83500e pipeline-milestone-step:100.v60a_03cd446e1 pipeline-model-api:2.2064.v5eef7d0982b_e pipeline-model-definition:2.2064.v5eef7d0982b_e pipeline-model-extensions:2.2064.v5eef7d0982b_e pipeline-rest-api:2.21 pipeline-stage-step:291.vf0a8a7aeeb50 pipeline-stage-tags-metadata:2.2064.v5eef7d0982b_e pipeline-stage-view:2.21 plain-credentials:1.8 plot:2.1.10 plugin-util-api:2.13.0 popper-api:1.16.1-2 popper2-api:2.11.2-1 postbuildscript:3.1.0-369.vb_cc225753c4b_ preSCMbuildstep:0.3 prism-api:1.26.0-2 pubsub-light:1.16 rebuild:1.33 resource-disposer:0.17 saml:2.1.1-275.va_5718591a_999 scm-api:595.vd5a_df5eb_0e39 script-security:1131.v8b_b_5eda_c328e snakeyaml-api:1.29.1 sse-gateway:1.25 ssh-credentials:1.19 ssh-slaves:1.33.0 sshd:3.1.0 structs:308.v852b473a2b8c timestamper:1.17 token-macro:277.v7c8f82a_d66b_3 trilead-api:1.0.13 variant:1.4 violation-comments-to-github:1.95 warnings-ng:9.11.0 windows-slaves:1.8 workflow-aggregator:2.6 workflow-api:1136.v7f5f1759dc16 workflow-basic-steps:937.v7a_b_7579e07a_3 workflow-cps:2648.va9433432b33c workflow-cps-global-lib:552.vd9cc05b8a2e1 workflow-durable-task-step:1121.va_65b_d2701486 workflow-job:1167.v8fe861b_09ef9 workflow-multibranch:706.vd43c65dec013 workflow-scm-step:2.13 workflow-step-api:622.vb_8e7c15b_c95a_ workflow-support:813.vb_d7c3d2984a_0 ws-cleanup:0.40 xunit:3.0.5 ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Linux

Reproduction steps

I pretty much used the documentation-page here (https://plugins.jenkins.io/violation-comments-to-github/) but with bot syntaxes I get the error below.

I already checked the source-code, but could not find anything that would help me, since the pattern is always a single string.

Expected Results

No error

Actual Results

Step does not take a single required parameter - use named parameters instead @ line 139, column 19.
                     pattern(".*phpstan.*\\.xml\$")

Anything else?

Here's the full pipeline-step, which triggers this error:

      violationsToGitHubRecorder {
        config {
          gitHubUrl("https://api.github.com/")
          repositoryOwner("\$PULL_REQUEST_BASE_OWNER")
          repositoryName("\$PULL_REQUEST_BASE_REPO")
          pullRequestId("\$PULL_REQUEST_ID")

          // Only specify one of these!
          credentialsId("github-jenkins-token")

          createSingleFileComments(true)
          createCommentWithAllSingleFileComments(true)
          commentOnlyChangedContent(true)
          commentOnlyChangedFiles(true)
          keepOldComments(false)

          commentTemplate("""
          **Reporter**: {{violation.reporter}}{{#violation.rule}}

          **Rule**: {{violation.rule}}{{/violation.rule}}
          **Severity**: {{violation.severity}}
          **File**: {{violation.file}} L{{violation.startLine}}{{#violation.source}}

          **Source**: {{violation.source}}{{/violation.source}}

          {{violation.message}}
          """)

          violationConfigs: [[
                  parser: 'CHECKSTYLE',
                  pattern: '.*phpstan.*\\.xml$',
                  reporter: 'PHPStan'
              ], [
                  parser: 'CPD',
                  pattern: '.*php-cpd.xml$',
                  reporter: 'PHP Copy/Paste Detector'
              ]
          ]
        }
      }
tomasbjerre commented 2 years ago

So you trying to use job dsl, declarative pipeline or scripted pipeline?

I would suggest using the built in snippet generator to get it right. https://www.jenkins.io/doc/book/pipeline/getting-started/

mkrauser commented 2 years ago

@tomasbjerre Thank you, that helped