mkobit / jenkins-pipeline-shared-library-example

Basic template example of a Jenkins Pipelines Shared Library that is tested using https://github.com/mkobit/jenkins-pipeline-shared-libraries-gradle-plugin
MIT License
70 stars 34 forks source link

java.lang.UnsupportedOperationException: no known implementation of class hudson.scm.SCM is named GitSCM #7

Closed peidong-hu closed 5 years ago

peidong-hu commented 5 years ago

Hi,

I have wrote my code to test this vars declaritive pipeline,

def call(String var_codeRepoBranch, String var_codeRepoUrl) { node { try { checkout([$class: 'GitSCM', branches: [[name: var_codeRepoBranch]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'peidong_bitbucket_eco', url: var_codeRepoUrl]]]) //git branch: var_codeRepoBranch, credentialsId: 'peidong_bitbucket_eco', url: var_codeRepoUrl echo "first checkout done" } } }

But I got following error in the integrationtest. After debug, I have found that the problem is that gradle sharedlibrary dependency has no plugin, "org.jenkinsci.plugins", "git".

But the latest plugin is in Maven repo, however the program is just trying to download it from jenkins-ci repo, and that repo has only very old git plugin here, https://repo.jenkins-ci.org/public/org/jenkinsci/plugins/git/

I think the gradle plugin needs to be changed to download the jenkins-ci stuff from maven repo

Running on Jenkins in /tmp/j h2322993632165826436/workspace/project [Pipeline] { [Pipeline] checkout [Pipeline] echo first checkout failed [Pipeline] retry [Pipeline] { [Pipeline] checkout [Pipeline] } ERROR: Execution failed java.lang.UnsupportedOperationException: no known implementation of class hudson.scm.SCM is named GitSCM at org.jenkinsci.plugins.structs.describable.DescribableModel.resolveClass(DescribableModel.java:478) at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:402) at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:341) at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:282) at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:202) at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:262) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:176) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122) at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1295)

peidong-hu commented 5 years ago

ok. after I add this in build.gradle.kts,

repositories { maven(url = "https://repo.jenkins-ci.org/releases/") jcenter() }

and dependency("org.jenkins-ci.plugins", "git", "3.9.4") in plugindependencies it works now