jfrog / jenkins-artifactory-plugin

Jenkins artifactory plugin
http://jenkins-ci.org/
116 stars 189 forks source link

Can't build w/gradle 6.6 "Prefix string too short" #349

Closed Andy-L closed 4 years ago

Andy-L commented 4 years ago

Describe the bug A Jenkins build using the artifactory plugin and java 8 fails on gradle 6.6 (or 6.6.1) with the error:

Failed to create Jar file /home/****/.gradle/caches/jars-8/8535adf040d7c5fdb7fd6bc28bb0ef3f/ok.
> Prefix string too short

It happens even using "help" as the gradle task, which only runs scripts, so it isn't related to my build config.

A longer snippet of the log:

Executing command: "/home/****/agent/workspace/Foo_build_PR-41/gradlew" "--init-script" "/home/****/agent/workspace/Foo_build_PR-41@tmp/artifactory/init-artifactory8029803477712348087gradle" "--stacktrace" "--no-build-cache" "help" "-b" "./build.gradle" 

Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

* What went wrong:
Failed to create Jar file /home/****/.gradle/caches/jars-8/8535adf040d7c5fdb7fd6bc28bb0ef3f/ok.
> Prefix string too short

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.GradleException: Failed to create Jar file /home/****/.gradle/caches/jars-8/8535adf040d7c5fdb7fd6bc28bb0ef3f/ok.
    at org.gradle.internal.classpath.ClasspathBuilder.jar(ClasspathBuilder.java:47)
    at org.gradle.internal.classpath.InstrumentingClasspathFileTransformer.transform(InstrumentingClasspathFileTransformer.java:76)
    at org.gradle.internal.classpath.InstrumentingClasspathFileTransformer.transform(InstrumentingClasspathFileTransformer.java:70)
    at org.gradle.internal.classpath.DefaultCachedClasspathTransformer$TransformFile.lambda$schedule$0(DefaultCachedClasspathTransformer.java:261)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: java.lang.IllegalArgumentException: Prefix string too short
    at org.gradle.internal.classpath.ClasspathBuilder.buildJar(ClasspathBuilder.java:53)
    at org.gradle.internal.classpath.ClasspathBuilder.jar(ClasspathBuilder.java:45)
    ... 6 more

To Reproduce Build a gradle java project using the artifactory plugin and gradle 6.6 or 6.6.1.

Expected behavior The gradle build proceeds normally and builds the project.

Versions

Additional context It looks like the ok is coming from a marker file in the dependencies directory (near the bottom):

-rw-r--r-- 1 jenkins jenkins  896477 Oct  6 17:14 docker-java-3.1.2.jar
-rw-r--r-- 1 jenkins jenkins 2256213 Oct  6 17:14 guava-18.0.jar
-rw-r--r-- 1 jenkins jenkins  186763 Oct  6 17:14 hk2-api-2.5.0-b42.jar
-rw-r--r-- 1 jenkins jenkins  189454 Oct  6 17:14 hk2-locator-2.5.0-b42.jar
-rw-r--r-- 1 jenkins jenkins  135317 Oct  6 17:14 hk2-utils-2.5.0-b42.jar
-rw-r--r-- 1 jenkins jenkins  774640 Oct  6 17:14 httpclient-4.5.10.jar
-rw-r--r-- 1 jenkins jenkins  327373 Oct  6 17:14 httpcore-4.4.5.jar
-rw-r--r-- 1 jenkins jenkins 1282424 Oct  6 17:14 ivy-2.4.0.jar
-rw-r--r-- 1 jenkins jenkins   66983 Oct  6 17:14 jackson-annotations-2.9.5.jar
-rw-r--r-- 1 jenkins jenkins  348625 Oct  6 17:14 jackson-core-2.10.1.jar
-rw-r--r-- 1 jenkins jenkins 1403051 Oct  6 17:14 jackson-databind-2.10.1.jar
-rw-r--r-- 1 jenkins jenkins   32373 Oct  6 17:14 jackson-jaxrs-base-2.9.8.jar
-rw-r--r-- 1 jenkins jenkins   15861 Oct  6 17:14 jackson-jaxrs-json-provider-2.9.8.jar
-rw-r--r-- 1 jenkins jenkins   32627 Oct  6 17:14 jackson-module-jaxb-annotations-2.9.8.jar
-rw-r--r-- 1 jenkins jenkins  737884 Oct  6 17:14 javassist-3.22.0-CR2.jar
-rw-r--r-- 1 jenkins jenkins   26366 Oct  6 17:14 javax.annotation-api-1.2.jar
-rw-r--r-- 1 jenkins jenkins    5951 Oct  6 17:14 javax.inject-2.5.0-b42.jar
-rw-r--r-- 1 jenkins jenkins  127509 Oct  6 17:14 javax.ws.rs-api-2.1.jar
-rw-r--r-- 1 jenkins jenkins   16515 Oct  6 17:14 jcl-over-slf4j-1.7.25.jar
-rw-r--r-- 1 jenkins jenkins  153115 Oct  6 17:14 jdom-1.1.jar
-rw-r--r-- 1 jenkins jenkins   24492 Oct  6 17:14 jersey-apache-connector-2.27.jar
-rw-r--r-- 1 jenkins jenkins  181563 Oct  6 17:14 jersey-client-2.27.jar
-rw-r--r-- 1 jenkins jenkins 1140395 Oct  6 17:14 jersey-common-2.27.jar
-rw-r--r-- 1 jenkins jenkins   62547 Oct  6 17:14 jersey-hk2-2.27.jar
-rw-r--r-- 1 jenkins jenkins   19936 Oct  6 17:14 jsr305-3.0.2.jar
-rw-r--r-- 1 jenkins jenkins   76413 Oct  6 17:14 junixsocket-common-2.2.0.jar
-rw-r--r-- 1 jenkins jenkins  246975 Oct  6 17:14 junixsocket-native-common-2.2.0.jar
-rw-r--r-- 1 jenkins jenkins   71976 Oct  6 17:14 jzlib-1.1.3.jar
-rw-r--r-- 1 jenkins jenkins   67574 Oct  6 17:14 maven-artifact-manager-2.2.1.jar
-rw-r--r-- 1 jenkins jenkins   34130 Oct  6 17:14 maven-deploy-plugin-2.8.2.jar
-rw-r--r-- 1 jenkins jenkins  163733 Oct  6 17:14 maven-model-3.1.0.jar
-rw-r--r-- 1 jenkins jenkins   29710 Oct  6 17:14 maven-plugin-registry-2.2.1.jar
-rw-r--r-- 1 jenkins jenkins   35362 Oct  6 17:14 maven-profile-2.2.1.jar
-rw-r--r-- 1 jenkins jenkins  156283 Oct  6 17:14 maven-project-2.2.1.jar
-rw-r--r-- 1 jenkins jenkins  273373 Oct  6 17:14 netty-buffer-4.1.31.Final.jar
-rw-r--r-- 1 jenkins jenkins  316560 Oct  6 17:14 netty-codec-4.1.31.Final.jar
-rw-r--r-- 1 jenkins jenkins  563216 Oct  6 17:14 netty-codec-http-4.1.31.Final.jar
-rw-r--r-- 1 jenkins jenkins  119353 Oct  6 17:14 netty-codec-socks-4.1.31.Final.jar
-rw-r--r-- 1 jenkins jenkins  586456 Oct  6 17:14 netty-common-4.1.31.Final.jar
-rw-r--r-- 1 jenkins jenkins  419511 Oct  6 17:14 netty-handler-4.1.31.Final.jar
-rw-r--r-- 1 jenkins jenkins   21275 Oct  6 17:14 netty-handler-proxy-4.1.31.Final.jar
-rw-r--r-- 1 jenkins jenkins   32800 Oct  6 17:14 netty-resolver-4.1.31.Final.jar
-rw-r--r-- 1 jenkins jenkins  463017 Oct  6 17:14 netty-transport-4.1.31.Final.jar
-rw-r--r-- 1 jenkins jenkins  141019 Oct  6 17:14 netty-transport-native-epoll-4.1.31.Final.jar
-rw-r--r-- 1 jenkins jenkins  109799 Oct  6 17:14 netty-transport-native-kqueue-4.1.31.Final.jar
-rw-r--r-- 1 jenkins jenkins   33471 Oct  6 17:14 netty-transport-native-unix-common-4.1.31.Final.jar
-rw-r--r-- 1 jenkins jenkins       0 Oct  6 17:14 ok
-rw-r--r-- 1 jenkins jenkins   20235 Oct  6 17:14 osgi-resource-locator-1.0.1.jar
-rw-r--r-- 1 jenkins jenkins   52684 Oct  6 17:14 plexus-classworlds-2.5.2.jar
-rw-r--r-- 1 jenkins jenkins  191978 Oct  6 17:14 plexus-container-default-1.0-alpha-6.jar
-rw-r--r-- 1 jenkins jenkins  160382 Oct  6 17:14 plexus-utils-1.0.2.jar
-rw-r--r-- 1 jenkins jenkins   41203 Oct  6 17:14 slf4j-api-1.7.25.jar

...which is created by PluginDependencyHelper.

It looks like gradle 6.6 is now trying to cache all of the dependencies in its own dependency cache, and failing on ok because it is too short of a filename.

sfgroups-k8s commented 4 years ago

getting same error for gradle task. using Gradle 6.7

 stage('Compile') {
                        task ('Exec Gradle') {
                            rtGradle.run rootDir: ".", buildFile: 'build.gradle', tasks: 'clean assemble', buildInfo: buildInfo
                        }
                    }
17:09:19  Starting a Gradle Daemon (subsequent builds will be faster)
17:09:22  
17:09:22  FAILURE: Build failed with an exception.
17:09:22  
17:09:22  * What went wrong:
17:09:22  Failed to create Jar file /home/xxxx/.gradle/caches/jars-8/8535adf040d7c5fdb7fd6bc28bb0ef3f/ok.
17:09:22  > Prefix string too short
17:09:22  
17:09:22  * Try:
17:09:22  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
17:09:22  
17:09:22  * Get more help at https://help.gradle.org
17:09:22  
17:09:22  BUILD FAILED in 4s
[Pipeline] }
[Pipeline] // task
[Pipeline] }
[Pipeline] // stage
[Pipeline] echo
17:09:23  java.lang.RuntimeException: Gradle build failed
yahavi commented 4 years ago

@sfgroups-k8s @Andy-L, Thanks for reporting this issue. The fix is already included in the latest Jenkins Artifactory plugin 3.9.0. Feel free to upgrade. We'd appreciate your feedback for that!