jenkinsci / configuration-as-code-plugin

Jenkins Configuration as Code Plugin
https://plugins.jenkins.io/configuration-as-code
MIT License
2.69k stars 718 forks source link

Invalid configuration elements for type class com.github.kostyasha.github.integration.multibranch.GitHubSCMSource #1269

Closed efernandes-dev-ops closed 4 years ago

efernandes-dev-ops commented 4 years ago

Your checklist for this issue

🚨 Please review the guidelines for contributing to this repository.

Description

We are currently getting the following error trying to configure global shared libraries on jenkins.

I added the configuration first on jenkins via the UI and then extracted the following using JCasC plugin:

unclassified:
  globalLibraries:
    libraries:
    - defaultVersion: "master"
      implicit: true
      includeInChangesets: false
      name: "global"
      retriever:
        modernSCM:
          scm:
            github:
              configuredByUrl: false
              credentialsId: "github-credentials"
              id: "2a0da7cf-3deb-4a50-acdc-53325305d743"
              repoOwner: "test"
              repository: "devops-jenkins-library"
              repositoryUrl: "test"

However we get the following error on startup:

io.jenkins.plugins.casc.ConfiguratorException: Invalid configuration elements for type class com.github.kostyasha.github.integration.multibranch.GitHubSCMSource : repoOwner,credentialsId,repository,configuredByUrl,repositoryUrl.
Available attributes : handlers, id, projectUrlStr, repoProvider, scmFactory, traits
        at io.jenkins.plugins.casc.BaseConfigurator.handleUnknown(BaseConfigurator.java:377)
        at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:366)
        at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:276)
        at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.configure(DataBoundConfigurator.java:83)
        at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$doConfigure$16668e2$1(HeteroDescribableConfigurator.java:278)
        at io.vavr.CheckedFunction0.lambda$unchecked$52349c75$1(CheckedFunction0.java:247)
        at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.doConfigure(HeteroDescribableConfigurator.java:278)
        at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$null$2(HeteroDescribableConfigurator.java:86)
        at io.vavr.control.Option.map(Option.java:392)
        at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$configure$3(HeteroDescribableConfigurator.java:86)
        at io.vavr.Tuple2.apply(Tuple2.java:238)
        at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.configure(HeteroDescribableConfigurator.java:83)
        at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.configure(HeteroDescribableConfigurator.java:55)
        at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:160)
        at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.instance(DataBoundConfigurator.java:77)
        at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:267)
        at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.configure(DataBoundConfigurator.java:83)
        at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$doConfigure$16668e2$1(HeteroDescribableConfigurator.java:278)
        at io.vavr.CheckedFunction0.lambda$unchecked$52349c75$1(CheckedFunction0.java:247)
        at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.doConfigure(HeteroDescribableConfigurator.java:278)
        at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$null$2(HeteroDescribableConfigurator.java:86)
        at io.vavr.control.Option.map(Option.java:392)
        at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$configure$3(HeteroDescribableConfigurator.java:86)
        at io.vavr.Tuple2.apply(Tuple2.java:238)
        at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.configure(HeteroDescribableConfigurator.java:83)
        at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.configure(HeteroDescribableConfigurator.java:55)
        at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.tryConstructor(DataBoundConfigurator.java:160)
        at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.instance(DataBoundConfigurator.java:77)
        at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:267)
        at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.check(DataBoundConfigurator.java:101)
        at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:344)
        at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:287)
        at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:352)
        at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:287)
        at io.jenkins.plugins.casc.ConfigurationAsCode.lambda$checkWith$7(ConfigurationAsCode.java:746)
        at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:696)
timja commented 4 years ago

What plugins do you have installed?

efernandes-dev-ops commented 4 years ago

@timja Here's a list of all the plugins I've got installed

"ace-editor:1.1", "allure-jenkins-plugin:2.28.1", "analysis-core:1.96", "analysis-model-api:7.0.4", "ansicolor:0.6.2", "antisamy-markup-formatter:1.8", "apache-httpcomponents-client-4-api:4.5.10-2.0", "authentication-tokens:1.3", "aws-credentials:1.28", "aws-global-configuration:1.3", "aws-java-sdk:1.11.700", "basic-branch-build-strategies:1.3.2", "blueocean-autofavorite:1.2.4", "blueocean-bitbucket-pipeline:1.22.0", "blueocean-commons:1.22.0", "blueocean-config:1.22.0", "blueocean-core-js:1.22.0", "blueocean-dashboard:1.22.0", "blueocean-display-url:2.3.0", "blueocean-events:1.22.0", "blueocean-executor-info:1.22.0", "blueocean-git-pipeline:1.22.0", "blueocean-github-pipeline:1.22.0", "blueocean-i18n:1.22.0", "blueocean-jira:1.22.0", "blueocean-jwt:1.22.0", "blueocean-personalization:1.22.0", "blueocean-pipeline-api-impl:1.22.0", "blueocean-pipeline-editor:1.22.0", "blueocean-pipeline-scm-api:1.22.0", "blueocean-rest-impl:1.22.0", "blueocean-rest:1.22.0", "blueocean-web:1.22.0", "blueocean:1.22.0", "bouncycastle-api:2.18", "branch-api:2.5.5", "build-monitor-plugin:1.12+build.201809061734", "cloudbees-bitbucket-branch-source:2.7.0", "cloudbees-folder:6.11.1", "cobertura:1.15", "code-coverage-api:1.1.3", "command-launcher:1.4", "conditional-buildstep:1.3.6", "config-file-provider:3.6.3", "configuration-as-code:1.35", "copyartifact:1.43", "credentials-binding:1.20", "credentials:2.3.1", "cucumber-reports:5.0.2", "dashboard-view:2.12", "display-url-api:2.3.2", "docker-commons:1.16", "docker-workflow:1.21", "durable-task:1.33", "ec2:1.49.1", "favorite:2.3.2", "forensics-api:0.6.1", "gatling:1.2.7", "git-client:3.1.1", "git-server:1.9", "git:4.1.1", "github-api:1.106", "github-branch-source:2.5.8", "github-oauth:0.33", "github-pullrequest:0.2.6", "github:1.29.5", "google-oauth-plugin:1.0.0", "gravatar:2.1", "handlebars:1.1.1", "handy-uri-templates-2-api:2.1.8-1.0", "hashicorp-vault-plugin:3.1.1", "htmlpublisher:1.21", "http_request:1.8.24", "icon-shim:2.0.3", "jackson2-api:2.10.2", "jacoco:3.0.5", "javadoc:1.5", "jdk-tool:1.4", "jenkins-design-language:1.22.0", "jira:3.0.12", "job-dsl:1.76", "jobConfigHistory:2.24", "jquery-detached:1.2.1", "jquery:1.12.4-1", "jsch:0.1.55.2", "junit:1.28", "kubernetes-client-api:4.6.4-2", "kubernetes-credentials:0.6.0", "kubernetes:1.23.2", "lockable-resources:2.7", "mailer:1.30", "matrix-auth:2.5", "matrix-project:1.14", "maven-plugin:3.4", "mercurial:2.8", "metrics:4.0.2.6", "momentjs:1.1.1", "multiple-scms:0.6", "node-iterator-api:1.5.0", "oauth-credentials:0.4", "Office-365-Connector:4.12.2", "parameterized-trigger:2.36", "pipeline-aws:1.39", "pipeline-build-step:2.11", "pipeline-graph-analysis:1.10", "pipeline-input-step:2.11", "pipeline-milestone-step:1.3.1", "pipeline-model-api:1.5.1", "pipeline-model-declarative-agent:1.1.1", "pipeline-model-definition:1.5.1", "pipeline-model-extensions:1.5.1", "pipeline-rest-api:2.13", "pipeline-stage-step:2.3", "pipeline-stage-tags-metadata:1.5.1", "pipeline-stage-view:2.13", "pipeline-utility-steps:2.5.0", "plain-credentials:1.7", "prometheus:2.0.6", "pubsub-light:1.13", "resource-disposer:0.14", "role-strategy:2.16", "run-condition:1.2", "s3:0.11.3", "saml:1.1.5", "scm-api:2.6.3", "script-security:1.69", "simple-theme-plugin:0.5.1", "sse-gateway:1.20", "ssh-agent:1.19", "ssh-credentials:1.18.1", "ssh-slaves:1.31.1", "structs:1.20", "timestamper:1.10", "token-macro:2.10", "trilead-api:1.0.5", "variant:1.3", "view-job-filters:2.1.1", "warnings-ng:7.3.0", "webhook-step:1.4", "windows-slaves:1.6", "workflow-aggregator:2.6", "workflow-api:2.39", "workflow-basic-steps:2.19", "workflow-cps-global-lib:2.15", "workflow-cps:2.78", "workflow-durable-task-step:2.35", "workflow-job:2.36", "workflow-multibranch:2.21", "workflow-scm-step:2.10", "workflow-step-api:2.22", "workflow-support:3.4", "ws-cleanup:0.38"

efernandes-dev-ops commented 4 years ago

@timja any ideas?

timja commented 4 years ago

The only reference I can find to that class is this plugin: https://github.com/KostyaSha/github-integration-plugin/blob/master/github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/GitHubSCMSource.java

which isn't the right GitHubSCMSource (https://github.com/jenkinsci/github-branch-source-plugin/blob/master/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java)

jetersen commented 4 years ago

As the github-pullrequest-plugin is not hosted in Jenkins CI this is outside the scope of JCasC and our goal for plugin compatibility.

Please use one of the official Github SCM source plugins such as github-branch-source-plugin

wesley-c42 commented 4 years ago

If you have both the github-branch-source plugin and the github-pullrequest plugin installed, the configuration as code reference will show:

SCMSource
Possible values:
bitbucket
git
github
gitHub
mercurial
fromScm
subversion

Using github should have let you use the github-branch-source plugin's source management. However, both github and gitHub value will give the above mentioned error. Deleting the github-pullrequest plugin, will fix this.