在Jenkinsfile

时间:2018-11-08 13:59:27

标签: jenkins groovy jenkins-pipeline pipeline

如这些文档中所述 https://jenkins.io/doc/book/pipeline/shared-libraries/ http://docs.groovy-lang.org/latest/html/documentation/grape.html#_quick_start

我想在我的Jenkinsfile中使用@Grab,但出现错误

@Grab('com.blabla:MyArtifact:0.1.0')

import com.blabla.MyClass

我有这个错误

  

java.lang.RuntimeException:未找到合适的ClassLoader进行抓取       在sun.reflect.GeneratedConstructorAccessor25608.newInstance(未知来源)       在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)       在java.lang.reflect.Constructor.newInstance(Constructor.java:423)       在org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)       在org.codehaus.groovy.runtime.callsite.ConstructorSite $ ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)处       在org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)       在org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)       在org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)       在groovy.grape.GrapeIvy.chooseClassLoader(GrapeIvy.groovy:182)       在groovy.grape.GrapeIvy $ chooseClassLoader.callCurrent(未知来源)       在groovy.grape.GrapeIvy.grab(GrapeIvy.groovy:249)       在groovy.grape.Grape.grab(Grape.java:167)       在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处       在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)       在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)       在java.lang.reflect.Method.invoke(Method.java:498)       在org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)       在groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)       在org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:46)       在org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:102)       在org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)       在org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)       在org.kohsuke.groovy.sandbox.impl.Checker $ 2.call(Checker.java:188)       在org.kohsuke.groovy.sandbox.impl.Checker.checkedStaticCall(Checker.java:190)       在org.kohsuke.groovy.sandbox.impl.Checker $ checkedStaticCall $ 6.callStatic(未知来源)       在org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)       在org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)       在org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:222)       在WorkflowScript中。(WorkflowScript)   原因:java.lang.ExceptionInInitializerError       在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)处       在sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)       在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)       在java.lang.reflect.Constructor.newInstance(Constructor.java:423)       在java.lang.Class.newInstance(Class.java:442)       在org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:434)       在groovy.lang.GroovyShell.parse(GroovyShell.java:700)       在org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:131)       在org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:125)       在org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:560)       在org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:521)       在org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:330)       在hudson.model.ResourceController.execute(ResourceController.java:97)       在hudson.model.Executor.run(Executor.java:429)   完成:失败

我检查了我的工件,而我的工件实际上在里面。如果我尝试获取错误的版本,则会遇到另一个错误。

0 个答案:

没有答案