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

huangapple go评论69阅读模式
英文:

Publishing a snapshot JAR to Artifactory Maven repository fails to deploy

问题

My team is trying to deploy a JAR generated by a Jenkins job to a repository in our Artifactory Pro 7.6.2 instance that is set up as a Maven snapshot repo. However, when performing the actual upload of the generated JAR file from the project the deploy fails with an error 500.

This is what is in the console output of the Jenkins job:

[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
...

On the Artifactory server side, the following is shown in log when this fails (this is repeated for each file that failed, just putting one example here):

2020-08-18T22:27:33.042Z [jfrt ] [ERROR] ... 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)
	...
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)
	...

The Jenkins job is a declarative multibranch pipeline and the Artifactory deployment is done via the following code within the 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")
    }
...

The project itself is a Java project built with 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()
}

[Additional content...]

英文:

My team is trying to deploy a JAR generated by a Jenkins job to a repository in our Artifactory Pro 7.6.2 instance that is set up as a Maven snapshot repo. However, when performing the actual upload of the generated JAR file from the project the deploy fails with an error 500.

This is what is in the console output of the Jenkins job:

[consumer_0] Deploying artifact: http://&lt;artifactory URL&gt;/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://&lt;artifactory URL&gt;/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://&lt;artifactory URL&gt;/maven-dev/com/example/example-client/0.0.1-SNAPSHOT/example-client-0.0.1-20200817.130343-1.jar
[consumer_1] Deploying artifact: http://&lt;artifactory URL&gt;/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

On the Artifactory server side, the following is shown in log when this fails (this is repeated for each file that failed, just putting one example here):

2020-08-18T22:27:33.042Z [jfrt ] [ERROR] [6c7ca1a483dd3f03] [o.a.r.d.DbStoringRepoMixin:291] [tp-nio-8081-exec-407] - Couldn&#39;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

The Jenkins job is a declarative multibranch pipeline and the Artifactory deployment is done via the following code within the Jenkinsfile:

...
dir(&quot;mavenOut/snapshot/&quot;){
rtBuildInfo(maxBuilds: 10)
rtUpload(
serverId: &quot;artifactory&quot;, 
spec: &quot;&quot;&quot;{
&quot;files&quot;:[
{
&quot;pattern&quot;: &quot;**/*&quot;,
&quot;excludePatterns&quot;: [&quot;*maven-metadata.xml&quot;, &quot;*.sha1&quot;,&quot;*.sha256&quot;,&quot;*.sha512&quot;,&quot;*.md5&quot;],
&quot;target&quot;:  &quot;maven-dev/&quot;,
&quot;flat&quot;: &quot;false&quot;
}
]
}&quot;&quot;&quot;
)
rtPublishBuildInfo(serverId: &quot;artifactory&quot;)
}
...

The project itself is a Java project built with Gradle:

plugins {
id &#39;java-library&#39;
id &#39;maven-publish&#39;
id &#39;maven&#39;
}
group = &#39;com.example&#39;
version = &#39;0.0.1-SNAPSHOT&#39;
sourceCompatibility = &#39;1.8&#39;
repositories {
mavenCentral()
}
dependencies {
implementation &#39;javax.websocket:javax.websocket-api:1.0&#39;
implementation &#39;org.springframework:spring-websocket:5.2.7.RELEASE&#39;
implementation &#39;org.springframework:spring-messaging:5.2.7.RELEASE&#39;
implementation &#39;com.fasterxml.jackson.core:jackson-databind:2.11.2&#39;
implementation &#39;com.google.code.gson:gson:2.8.6&#39;
implementation &#39;org.apache.tomcat.embed:tomcat-embed-websocket:9.0.37&#39;
testCompile(&#39;org.springframework.boot:spring-boot-starter-test:2.3.0.RELEASE&#39;) {
exclude group: &#39;org.junit.vintage&#39;, module: &#39;junit-vintage-engine&#39;
}
}
java {
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = &#39;example-client&#39;
from components.java
}
}
repositories {
maven {
def releasesRepoUrl = &quot;$buildDir/mavenOut/release&quot;
def snapshotsRepoUrl = &quot;$buildDir/mavenOut/snapshot&quot;
url = version.endsWith(&#39;SNAPSHOT&#39;) ? snapshotsRepoUrl : releasesRepoUrl
}
}
}
test {
useJUnitPlatform()
}

Ultimately, we end up with 5 files that need to get deployed (the timestamps change on each build of course):

  • example-client-0.0.1-20200817.130343-1.jar
  • example-client-0.0.1-20200817.130343-1-javadoc.jar
  • example-client-0.0.1-20200817.130343-1-sources.jar
  • example-client-0.0.1-20200817.130343-1.module
  • example-client-0.0.1-20200817.130343-1.pom

The Maven repository (maven-dev) within Artifactory is set up with the following settings:

  • Checksum policy: Verify against client checksums
  • Maven Snapshot Version Behavior: Unique
  • Max Unique Snapshots: <empty>
  • Handle Releases: unchecked
  • Handle Snapshots: checked
  • Suppress POM Consistency Checks: checked

I'm hoping that someone else has deployed a project like this to an Artifactory repo to point out what's going wrong. We've used Artifactory extensively for a number of years but not in the context of deploying snapshot builds to a Maven repository.

EDIT: I have narrowed down the issue to the fact that we're trying to upload the *-sources.jar in addition to the main jar and the *-javadoc.jar. If I update the exclude filter in the file spec to the following then the publish works flawlessly as expected:

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

So something about the sources.jar getting published is throwing it off, any ideas?

EDIT 2: Well, excluding the sources jar worked for several builds then it started failing again with the same error. It will work for a build or two then fail for a while, then back to a few successes it seems.

EDIT 3: I also tried deploying via the Artifactory Gradle syntax rather than the more generic rtUpload approach. The Gradle build runs and the buildinfo publishes but no artifacts are uploaded.

** EDIT 4:**
I got it working based on suggestions below. I also updated the Artifactory Jenkins plugin to the latest. Here's the snippet from the Jenkinsfile that ended up working just in case someone else runs into a similar issue.

   stage(&#39;Artifactory Config&#39;) {
steps {
rtBuildInfo(maxBuilds: 10, deleteBuildArtifacts: true)
rtGradleDeployer(
id: &quot;rtDeployer&quot;,
serverId: &quot;artifactory&quot;,
releaseRepo: &quot;gradle-release&quot;,
snapshotRepo: &quot;gradle-dev&quot;
)
rtGradleResolver(
id: &quot;rtResolver&quot;,
serverId: &quot;artifactory&quot;,
repo: &quot;maven&quot;
)
}
}
stage(&#39;Build Client&#39;){
steps {
echo &quot;invoking gradle&quot;
rtGradleRun(
tasks: &quot;artifactoryPublish&quot;,
useWrapper: true,
deployerId: &quot;rtDeployer&quot;,
resolverId: &quot;rtResolver&quot;
)
rtPublishBuildInfo(serverId: &quot;artifactory&quot;)
}
}

答案1

得分: 2

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

由于该插件是专门为Gradle构建开发的,与您当前使用的通用命令(rtUpload)不同,这可能会防止出现类似您现在面临的问题。

请参阅此Jenkinsfile示例,以了解如何在您的流水线中轻松使用此集成。

英文:

I would suggest building and deploying Gradle artifacts using the dedicated Gradle integration offered in the Jenkins Artifactory Plugin.

This might prevent issues like those you are facing now since it is developed specifically for Gradle builds, unlike the generic command (rtUpload) you are currently using.

See this Jenkinsfile example to learn how to easily use this integration in your pipeline.

答案2

得分: 1

根据错误日志片段,我可以看出错误与数据库事务中的死锁有关。我认为Artifactory正在使用默认的derby数据库。
以下错误日志片段表明Derby中发生了死锁情况,

Caused by: org.apache.derby.iapi.error.StandardException: 由于死锁无法获取锁,锁和等待者的循环为:
锁:行,节点,(2975,6)
等待的XID:{230127895,S},应用程序,SELECT * FROM nodes WHERE repo = ? AND node_path = ? AND depth = ?
获得的XID:{230127897,X}
锁:行,节点,(991,272)
等待的XID:{230127897,S},应用程序,SELECT * FROM nodes WHERE repo = ? AND node_path = ? AND depth = ?
获得的XID:{230127895,X}

我有一个类似的JenkinsFile,用于将构件部署到Artifactory,从未遇到过此问题。我相信简单地重新启动Artifactory应该足以将Derby数据库从死锁状态中移除。

英文:

Based on error log snippet, I could see that the error is related to the deadlock in the DB transactions. I think Artifactory is running with the default derby DB.
The below error log snippet tells that there was deadlock situation in 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}

I had a similar JenkinFile which deploys Artifacts to Artifactory and never faced this issue. I believe a simple restart of Artifactory should be enough to remove the Derby DB from the deadlock state.

huangapple
  • 本文由 发表于 2020年8月19日 07:45:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/63478131.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定