gpt4 book ai didi

jenkins - 无法解析 Jenkins 管道中的 groovyx.net.http.HTTPBuilder 类

转载 作者:行者123 更新时间:2023-12-02 18:39:25 25 4
gpt4 key购买 nike

我有一个 jenkins 管道脚本,它是从 jenkins 的另一个实例导入的,它运行时没有错误。

在当前实例上失败并出现导入错误

我无法修改我现在拥有的脚本。

我无法添加:

@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7' )

当我运行作业时,我收到如下错误

    unable to resolve class groovyx.net.http.HTTPBuilder
@ line 2, column 1.
import groovyx.net.http.HTTPBuilder
^
unable to resolve class groovyx.net.http.ContentType
@ line 3, column 1.
import static groovyx.net.http.ContentType. *
^

如何在不修改脚本的情况下将 http-builder jar 文件导入到我的 jenkins 环境中,或者是否有导入 jar 文件的 jenkins 插件?

这是堆栈跟踪(以防万一它有帮助)

at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)    at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:958)    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:605)    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:554)    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:254)    at groovy.lang.GroovyClassLoader.recompile(GroovyClassLoader.java:761)    at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:718)    at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:787)    at java.lang.ClassLoader.loadClass(ClassLoader.java:411)    at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell$TimingLoader.loadClass(CpsGroovyShell.java:160)    at java.lang.ClassLoader.loadClass(ClassLoader.java:411)    at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:677)    at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:787)    at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:775)    at org.jenkinsci.plugins.workflow.cps.global.UserDefinedGlobalVariable.getValue(UserDefinedGlobalVariable.java:54)    at org.jenkinsci.plugins.workflow.cps.CpsScript.getProperty(CpsScript.java:121)    at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:174)    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:456)    at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.getProperty(DefaultInvoker.java:34)    at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)    at idt.devops.GlobalBuildPipeline.runPipeline(/var/lib/jenkins/jobs/jenkins-spud/branches/master/builds/34/libs/coretech-devops-jenkins-globallib/src/idt/devops/GlobalBuildPipeline.groovy:37)    at ___cps.transform___(Native Method)    at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74)    at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)    at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:498)    at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)    at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)    at com.cloudbees.groovy.cps.Next.step(Next.java:83)    at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)    at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)    at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122)    at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261)    at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19)    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:35)    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:32)    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:32)    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:331)    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:82)    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:243)    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:231)    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)    at java.util.concurrent.FutureTask.run(FutureTask.java:266)    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)    at java.util.concurrent.FutureTask.run(FutureTask.java:266)    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)    at java.lang.Thread.run(Thread.java:748)

最佳答案

我也遇到了同样的问题。我试图在管道之外的函数中使用 @Grab,然后尝试在使用 library 声明性管道步骤导入的共享库函数中使用它,并得到同样的问题。

直到我在配置为全局共享库的共享库中使用它并使用 @Library() 注释将其加载到我的管道中时,它才起作用。

关于jenkins - 无法解析 Jenkins 管道中的 groovyx.net.http.HTTPBuilder 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49058922/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com