将快照 JAR 发布到 Artifactory Maven 存储库无法部署

Publishing a snapshot JAR to Artifactory Maven repository fails to deploy

我的团队正在尝试将 Jenkins 作业生成的 JAR 部署到我们的 Artifactory Pro 7.6.2 实例中的存储库,该实例设置为 Maven 快照存储库。但是,当从项目执行生成的 JAR 文件的实际上传时,部署失败并显示错误 500。

这是 Jenkins 作业的控制台输出中的内容:

[consumer_0] Deploying artifact: http://<artifactory URL>/maven-dev/com/example/example-client/0.0.1-SNAPSHOT/example-client-0.0.1-20200817.130343-1-javadoc.jar
[consumer_1] Deploying artifact: http://<artifactory URL>/maven-dev/com/example/example-client/0.0.1-SNAPSHOT/example-client-0.0.1-20200817.130343-1-sources.jar
[consumer_2] Deploying artifact: http://<artifactory URL>/maven-dev/com/example/example-client/0.0.1-SNAPSHOT/example-client-0.0.1-20200817.130343-1.jar
[consumer_1] Deploying artifact: http://<artifactory URL>/maven-dev/com/example/example-client/0.0.1-SNAPSHOT/example-client-0.0.1-20200817.130343-1.module
[consumer_0] An exception occurred during execution:
java.lang.RuntimeException: java.io.IOException: Failed to deploy file. Status code: 500 Response message: Artifactory returned the following errors: 
 Status code: 500
    at org.jfrog.build.extractor.clientConfiguration.util.spec.SpecDeploymentConsumer.consumerRun(SpecDeploymentConsumer.java:44)
    at org.jfrog.build.extractor.producerConsumer.ConsumerRunnableBase.run(ConsumerRunnableBase.java:11)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Failed to deploy file. Status code: 500 Response message: Artifactory returned the following errors: 
 Status code: 500
    at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.uploadFile(ArtifactoryBuildInfoClient.java:685)
    at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.doDeployArtifact(ArtifactoryBuildInfoClient.java:367)
    at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.deployArtifact(ArtifactoryBuildInfoClient.java:355)
    at org.jfrog.build.extractor.clientConfiguration.util.spec.SpecDeploymentConsumer.consumerRun(SpecDeploymentConsumer.java:39)
    ... 2 more

[consumer_1] An exception occurred during execution:
java.lang.RuntimeException: java.io.IOException: Failed to deploy file. Status code: 500 Response message: Artifactory returned the following errors: 
 Status code: 500
    at org.jfrog.build.extractor.clientConfiguration.util.spec.SpecDeploymentConsumer.consumerRun(SpecDeploymentConsumer.java:44)
    at org.jfrog.build.extractor.producerConsumer.ConsumerRunnableBase.run(ConsumerRunnableBase.java:11)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Failed to deploy file. Status code: 500 Response message: Artifactory returned the following errors: 
 Status code: 500
    at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.uploadFile(ArtifactoryBuildInfoClient.java:685)
    at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.doDeployArtifact(ArtifactoryBuildInfoClient.java:367)
    at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.deployArtifact(ArtifactoryBuildInfoClient.java:355)
    at org.jfrog.build.extractor.clientConfiguration.util.spec.SpecDeploymentConsumer.consumerRun(SpecDeploymentConsumer.java:39)
    ... 2 more

在 Artifactory 服务器端,失败时日志中显示以下内容(对每个失败的文件重复此操作,此处仅举一个示例):

2020-08-18T22:27:33.042Z [jfrt ] [ERROR] [6c7ca1a483dd3f03] [o.a.r.d.DbStoringRepoMixin:291] [tp-nio-8081-exec-407] - Couldn't save resource maven-dev:com/example/example-client/0.0.1-SNAPSHOT/example-client-0.0.1-20200818.222406-1-sources.jar, reason:
java.lang.reflect.UndeclaredThrowableException: null
    at com.sun.proxy.$Proxy46.next(Unknown Source)
    at org.artifactory.storage.db.fs.dao.NodesDao.getChildren(NodesDao.java:247)
    at org.artifactory.storage.db.fs.service.FileServiceImpl.loadChildren(FileServiceImpl.java:272)
    at org.artifactory.storage.fs.tree.FolderNode.getChildrenItemNode(FolderNode.java:74)
    at org.artifactory.storage.fs.tree.FolderNode.getChildren(FolderNode.java:56)
    at org.artifactory.maven.MavenMetadataCalculator.folderContainsPoms(MavenMetadataCalculator.java:422)
    at org.artifactory.maven.MavenMetadataCalculator.createSnapshotsMetadata(MavenMetadataCalculator.java:210)
    at org.artifactory.maven.MavenMetadataCalculator.calculateAndSet(MavenMetadataCalculator.java:179)
    at org.artifactory.maven.MavenMetadataCalculator.calculate(MavenMetadataCalculator.java:154)
    at org.artifactory.maven.MavenMetadataServiceImpl.calculateMavenMetadata(MavenMetadataServiceImpl.java:86)
    at jdk.internal.reflect.GeneratedMethodAccessor5156.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205)
    at com.sun.proxy.$Proxy242.calculateMavenMetadata(Unknown Source)
    at org.artifactory.repo.interceptor.MavenMetadataCalculationInterceptor.afterCreate(MavenMetadataCalculationInterceptor.java:73)
    at org.artifactory.repo.interceptor.storage.StorageInterceptorsImpl.afterCreate(StorageInterceptorsImpl.java:69)
    at jdk.internal.reflect.GeneratedMethodAccessor459.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205)
    at com.sun.proxy.$Proxy234.afterCreate(Unknown Source)
    at org.artifactory.repo.db.DbStoringRepoMixin.invokeAfterCreateInterceptors(DbStoringRepoMixin.java:407)
    at org.artifactory.repo.db.DbStoringRepoMixin.saveResource(DbStoringRepoMixin.java:245)
    at org.artifactory.repo.db.DbLocalRepo.saveResource(DbLocalRepo.java:162)
    at org.artifactory.repo.service.RepositoryServiceImpl.saveResourceInTransaction(RepositoryServiceImpl.java:1915)
    at jdk.internal.reflect.GeneratedMethodAccessor477.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
    at com.sun.proxy.$Proxy193.saveResourceInTransaction(Unknown Source)
    at org.artifactory.repo.service.RepositoryServiceImpl.saveResource(RepositoryServiceImpl.java:1903)
    at jdk.internal.reflect.GeneratedMethodAccessor526.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205)
    at com.sun.proxy.$Proxy193.saveResource(Unknown Source)
    at org.artifactory.engine.UploadServiceImpl.uploadItemWithContent(UploadServiceImpl.java:574)
    at org.artifactory.engine.UploadServiceImpl.uploadItemWithProvidedContent(UploadServiceImpl.java:554)
    at org.artifactory.engine.UploadServiceImpl.uploadItem(UploadServiceImpl.java:429)
    at org.artifactory.engine.UploadServiceImpl.uploadFile(UploadServiceImpl.java:420)
    at org.artifactory.engine.UploadServiceImpl.uploadArtifact(UploadServiceImpl.java:402)
    at org.artifactory.engine.UploadServiceImpl.adjustResponseAndUpload(UploadServiceImpl.java:223)
    at org.artifactory.engine.UploadServiceImpl.validateRequestAndUpload(UploadServiceImpl.java:189)
    at org.artifactory.engine.UploadServiceImpl.upload(UploadServiceImpl.java:132)
    at jdk.internal.reflect.GeneratedMethodAccessor520.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.artifactory.request.aop.RequestAdvice.invoke(RequestAdvice.java:67)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
    at com.sun.proxy.$Proxy238.upload(Unknown Source)
    at org.artifactory.webapp.servlet.RepoFilter.doUpload(RepoFilter.java:284)
    at org.artifactory.webapp.servlet.RepoFilter.execute(RepoFilter.java:176)
    at org.artifactory.webapp.servlet.RepoFilter.doFilter(RepoFilter.java:97)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.artifactory.webapp.servlet.AccessFilter.useAuthenticationAndContinue(AccessFilter.java:413)
    at org.artifactory.webapp.servlet.AccessFilter.authenticateAndExecute(AccessFilter.java:301)
    at org.artifactory.webapp.servlet.AccessFilter.doFilterInternal(AccessFilter.java:176)
    at org.artifactory.webapp.servlet.AccessFilter.doFilter(AccessFilter.java:127)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.artifactory.webapp.servlet.RequestFilter.doFilter(RequestFilter.java:78)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.artifactory.webapp.servlet.ArtifactoryCsrfFilter.doFilter(ArtifactoryCsrfFilter.java:86)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:164)
    at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:80)
    at org.artifactory.webapp.servlet.SessionFilter.doFilter(SessionFilter.java:62)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.artifactory.webapp.servlet.ArtifactoryTracingFilter.doFilter(ArtifactoryTracingFilter.java:27)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.artifactory.webapp.servlet.ArtifactoryFilter.doFilter(ArtifactoryFilter.java:126)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
    at org.apache.catalina.valves.rewrite.RewriteValve.invoke(RewriteValve.java:305)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:615)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1627)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.reflect.InvocationTargetException: null
    at jdk.internal.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.jfrog.storage.wrapper.ResultSetWrapper.invoke(ResultSetWrapper.java:85)
    ... 109 common frames omitted
Caused by: java.sql.SQLTransactionRollbackException: A lock could not be obtained due to a deadlock, cycle of locks and waiters is:
Lock : ROW, NODES, (2975,6)
  Waiting XID : {230127895, S} , APP, SELECT * FROM nodes WHERE repo = ? AND node_path = ? AND depth = ?
  Granted XID : {230127897, X} 
Lock : ROW, NODES, (991,272)
  Waiting XID : {230127897, S} , APP, SELECT * FROM nodes WHERE repo = ? AND node_path = ? AND depth = ?
  Granted XID : {230127895, X} 
. The selected victim is XID : 230127895.
    at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
    at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
    at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
    at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
    at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedResultSet.closeOnTransactionError(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedResultSet.movePosition(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedResultSet.next(Unknown Source)
    ... 113 common frames omitted
Caused by: org.apache.derby.iapi.error.StandardException: A lock could not be obtained due to a deadlock, cycle of locks and waiters is:
Lock : ROW, NODES, (2975,6)
  Waiting XID : {230127895, S} , APP, SELECT * FROM nodes WHERE repo = ? AND node_path = ? AND depth = ?
  Granted XID : {230127897, X} 
Lock : ROW, NODES, (991,272)
  Waiting XID : {230127897, S} , APP, SELECT * FROM nodes WHERE repo = ? AND node_path = ? AND depth = ?
  Granted XID : {230127895, X} 
. The selected victim is XID : 230127895.
    at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
    at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
    at org.apache.derby.impl.services.locks.Deadlock.buildException(Unknown Source)
    at org.apache.derby.impl.services.locks.ConcurrentLockSet.lockObject(Unknown Source)
    at org.apache.derby.impl.services.locks.ConcurrentLockSet.zeroDurationLockObject(Unknown Source)
    at org.apache.derby.impl.services.locks.AbstractPool.zeroDurationlockObject(Unknown Source)
    at org.apache.derby.impl.services.locks.ConcurrentPool.zeroDurationlockObject(Unknown Source)
    at org.apache.derby.impl.store.raw.xact.RowLocking2nohold.lockRecordForRead(Unknown Source)
    at org.apache.derby.impl.store.access.heap.HeapController.lockRow(Unknown Source)
    at org.apache.derby.impl.store.access.heap.HeapController.lockRow(Unknown Source)
    at org.apache.derby.impl.store.access.btree.index.B2IRowLocking3.lockRowOnPage(Unknown Source)
    at org.apache.derby.impl.store.access.btree.index.B2IRowLocking3._lockScanRow(Unknown Source)
    at org.apache.derby.impl.store.access.btree.index.B2IRowLockingRR.lockScanRow(Unknown Source)
    at org.apache.derby.impl.store.access.btree.BTreeForwardScan.fetchRows(Unknown Source)
    at org.apache.derby.impl.store.access.btree.BTreeScan.fetchNextGroup(Unknown Source)
    at org.apache.derby.impl.sql.execute.BulkTableScanResultSet.reloadArray(Unknown Source)
    at org.apache.derby.impl.sql.execute.BulkTableScanResultSet.getNextRowCore(Unknown Source)
    at org.apache.derby.impl.sql.execute.IndexRowToBaseRowResultSet.getNextRowCore(Unknown Source)
    at org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.getNextRowCore(Unknown Source)
    at org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.getNextRow(Unknown Source)
    ... 115 common frames omitted

Jenkins 作业是声明性多分支管道,Artifactory 部署是通过 Jenkinsfile 中的以下代码完成的:

...
    dir("mavenOut/snapshot/"){
        rtBuildInfo(maxBuilds: 10)

        rtUpload(
            serverId: "artifactory", 
            spec: """{
                "files":[
                    {
                        "pattern": "**/*",
                        "excludePatterns": ["*maven-metadata.xml", "*.sha1","*.sha256","*.sha512","*.md5"],
                        "target":  "maven-dev/",
                        "flat": "false"
                    }
                ]
            }"""
        )

        rtPublishBuildInfo(serverId: "artifactory")
    }
...

该项目本身是一个 Java 使用 Gradle 构建的项目:

plugins {
    id 'java-library'
    id 'maven-publish'
    id 'maven'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'javax.websocket:javax.websocket-api:1.0'
    implementation 'org.springframework:spring-websocket:5.2.7.RELEASE'
    implementation 'org.springframework:spring-messaging:5.2.7.RELEASE'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.11.2'
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'org.apache.tomcat.embed:tomcat-embed-websocket:9.0.37'
    
    testCompile('org.springframework.boot:spring-boot-starter-test:2.3.0.RELEASE') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}

java {
    withJavadocJar()
    withSourcesJar()
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            artifactId = 'example-client'
            from components.java
        }
    }
    repositories {
        maven {
            def releasesRepoUrl = "$buildDir/mavenOut/release"
            def snapshotsRepoUrl = "$buildDir/mavenOut/snapshot"
            url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
        }
    }
}

test {
    useJUnitPlatform()
}

最终,我们得到了 5 个需要部署的文件(当然每个构建的时间戳都会改变):

Artifactory 中的 Maven 存储库 (maven-dev) 使用以下设置进行设置:

我希望其他人已经将这样的项目部署到 Artifactory 存储库以指出问题所在。我们已经广泛使用 Artifactory 多年,但没有在将快照构建部署到 Maven 存储库的上下文中使用。

编辑: 我已将问题缩小到我们正在尝试上传 *-sources.jar 除了主 jar 和 * -javadoc.jar。如果我将文件规范中的排除过滤器更新为以下内容,则发布将按预期完美运行:

"excludePatterns": ["*maven-metadata.xml","*.sha1","*.sha256","*.sha512","*.md5","*sources.jar"],

所以关于 sources.jar 发表的一些事情正在被抛弃,有什么想法吗?

编辑 2: 好吧,排除了用于多个构建的源 jar 然后它再次开始失败并出现相同的错误。它适用于一两次构建,然后会失败一段时间,然后又恢复成几次成功。

编辑 3: 我还尝试通过 Artifactory Gradle 语法而不是更通用的 rtUpload 方法进行部署。 Gradle 构建运行并且构建信息发布但没有上传工件。

** 编辑 4:** 我根据以下建议让它工作。我也把 Artifactory Jenkins 插件更新到了最新。这是 Jenkinsfile 中的片段,它最终起作用,以防其他人遇到类似问题。

   stage('Artifactory Config') {
        steps {
            rtBuildInfo(maxBuilds: 10, deleteBuildArtifacts: true)
            
            rtGradleDeployer(
                id: "rtDeployer",
                serverId: "artifactory",
                releaseRepo: "gradle-release",
                snapshotRepo: "gradle-dev"
            )
            
            rtGradleResolver(
                id: "rtResolver",
                serverId: "artifactory",
                repo: "maven"
            )
        }
    }

    stage('Build Client'){
        steps {
            echo "invoking gradle"

            rtGradleRun(
                tasks: "artifactoryPublish",
                useWrapper: true,
                deployerId: "rtDeployer",
                resolverId: "rtResolver"
            )
            
            rtPublishBuildInfo(serverId: "artifactory")
        }
    }

根据错误日志片段,我可以看出该错误与数据库事务中的死锁有关。我认为 Artifactory 是 运行 默认的德比数据库。 下面的错误日志片段表明 Derby 中存在死锁情况,

Caused by: org.apache.derby.iapi.error.StandardException: A lock could not be obtained due to a deadlock, cycle of locks and waiters is: Lock : ROW, NODES, (2975,6) Waiting XID : {230127895, S} , APP, SELECT * FROM nodes WHERE repo = ? AND node_path = ? AND depth = ? Granted XID : {230127897, X} Lock : ROW, NODES, (991,272) Waiting XID : {230127897, S} , APP, SELECT * FROM nodes WHERE repo = ? AND node_path = ? AND depth = ? Granted XID : {230127895, X}

我有一个类似的 JenkinFile,它将 Artifacts 部署到 Artifactory,但从未遇到过这个问题。我相信只需重新启动 Artifactory 就足以将 Derby DB 从死锁状态中移除。

我建议使用 Jenkins Artifactory 插件中提供的专用 Gradle integration 构建和部署 Gradle 工件。

这可能会阻止您现在面临的问题,因为它是专门为 Gradle 构建开发的,与您当前使用的通用命令 (rtUpload) 不同。

查看此 Jenkinsfile example 以了解如何在您的管道中轻松使用此集成。