首页 > 解决方案 > Jenkins 的 Artifactory 插件 - 脚本化管道中的 NPM 安装失败

问题描述

我想为我的 NPM 项目的 Jenkins Scripted Pipeline 使用 Artifactory 插件。在 NPM 安装期间,我遇到了一个问题:

SEVERE: process hasn't exited
java.lang.IllegalThreadStateException: process hasn't exited
    at java.lang.UNIXProcess.exitValue(UNIXProcess.java:423)
    at org.jfrog.build.extractor.executor.CommandExecutor.exeCommand(CommandExecutor.java:78)
    at org.jfrog.build.extractor.npm.NpmDriver.runCommand(NpmDriver.java:80)
    at org.jfrog.build.extractor.npm.NpmDriver.install(NpmDriver.java:42)
    at org.jfrog.build.extractor.npm.extractor.NpmBuildInfoExtractor.runInstall(NpmBuildInfoExtractor.java:153)
    at org.jfrog.build.extractor.npm.extractor.NpmBuildInfoExtractor.extract(NpmBuildInfoExtractor.java:61)
    at org.jfrog.build.extractor.npm.extractor.NpmInstall.execute(NpmInstall.java:50)
    at org.jfrog.hudson.npm.NpmInstallCallable.invoke(NpmInstallCallable.java:53)
    at org.jfrog.hudson.npm.NpmInstallCallable.invoke(NpmInstallCallable.java:20)
    at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3085)
    at hudson.remoting.UserRequest.perform(UserRequest.java:212)
    at hudson.remoting.UserRequest.perform(UserRequest.java:54)
    at hudson.remoting.Request$2.run(Request.java:369)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    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)

我在 Jenkins 的 Scripted Pipeline 中使用 Jenkins 的Artifactory 插件(v. 3.2.2) 。我正在关注官方 Jfrog 文档

我已经以某种方式与 JFrog 支持保持联系,我已经在官方 Github中提出了一个问题,并在此处为 JFrog 支持提供了问题。

我已经将这个插件用于 maven Project 的脚本化管道,它工作正常。当我从package.json删除一些依赖项时,我试图调试这个问题很多,有时它会起作用。

这是我的 groovy 脚本中的配置。

def server = Artifactory.server 'artifacts-prod-01'
server.credentialsId = 'artifactory-credentials-id'
def rtNpm = Artifactory.newNpmBuild()
rtNpm.resolver server: server, repo: 'npm-main-dev'
withEnv(["PATH+NODEJS=${tool 'NodeJS 10'}/bin"]) {
        def buildInfo = rtNpm.install path: '.'
}

我希望已经安装了package.json中指定的所有包,但似乎在 npm install 期间有一个超时。我只有一个有趣的观点。我尝试在此处安装具有固定超时的快照版本,并此处进行以下修复,然后出现此错误:

[Bitbucket] Notifying commit build result
[Bitbucket] Build result notified
java.io.IOException: Unexpected EOF
    at hudson.remoting.ChunkedInputStream.readUntilBreak(ChunkedInputStream.java:99)
    at hudson.remoting.ChunkedCommandTransport.readBlock(ChunkedCommandTransport.java:39)
    at hudson.remoting.AbstractSynchronousByteArrayCommandTransport.read(AbstractSynchronousByteArrayCommandTransport.java:35)
    at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:63)
Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to stg-default-agent-eu
        at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1741)
        at hudson.remoting.Request.call(Request.java:202)
        at hudson.remoting.Channel.call(Channel.java:954)
        at hudson.FilePath.act(FilePath.java:1071)
        at hudson.FilePath.act(FilePath.java:1060)
        at org.jfrog.hudson.pipeline.common.executors.NpmInstallExecutor.execute(NpmInstallExecutor.java:57)
        at org.jfrog.hudson.pipeline.scripted.steps.NpmInstallStep$Execution.run(NpmInstallStep.java:64)
        at org.jfrog.hudson.pipeline.scripted.steps.NpmInstallStep$Execution.run(NpmInstallStep.java:39)
        at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
        at hudson.security.ACL.impersonate(ACL.java:290)
        at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
        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)
Caused: hudson.remoting.RequestAbortedException
    at hudson.remoting.Request.abort(Request.java:340)
    at hudson.remoting.Channel.terminate(Channel.java:1038)
    at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:96)
Finished: FAILURE

有没有人使用 Artifactory Jenkins 插件通过脚本管道构建他们的 NPM 项目?如果是的话,你能分享你的配置吗?非常感谢。

标签: jenkinsnpmpluginsartifactory

解决方案


自 Jenkins Artifactory 插件 v3.2.3 以来,此问题已得到解决。请升级到最新版本。有关更多信息,请参阅HAP-1165和此提交


推荐阅读