apache / apache/maven-build-cache-extension
[MBUILDCACHE-117] temp artifacts created by extension are not found in Jenkins pipeline job
- Dominant language
- Java
- Stars
- 163
- Forks
- 77
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 4
Description
**[Hu Wang](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=JIRAUSER308834)** opened **[MBUILDCACHE-117](https://issues.apache.org/jira/browse/MBUILDCACHE-117?redirect=false)** and commented
I am testing out this great extension 1.2.0 in Jenkins pipeline, I am using the example maven-build-cache-config.xml and it works great until I configured it with \ . The config is like:
\
\
\lib\
\
\
…
I am using Artifactory plugin in our Jenkins pipeline, it looks like:
buildInfo = rtMaven.run pom: "pom.xml", goals: “clean install”
Project is built fine, but it errored out when constructing the buildinfo and failed on File Not Found. Error is like below, in which the horizon-cache-test-scm is the module that has target/lib to be attached as an artifact, but the file /tmp/maven-incremental-4470226598730272536horizon-cache-test-scm has been deleted
**14:55:53** java.lang.IllegalArgumentException: **File not found: /tmp/maven-incremental-4470226598730272536horizon-cache-test-scm**
**14:55:53** at org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails$Builder.build(DeployDetails.java:153)
**14:55:53** at org.jfrog.hudson.pipeline.common.types.buildInfo.BuildInfo$DeployPathsAndPropsCallable.lambda$invoke$0(BuildInfo.java:396)
**14:55:53** at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:986)
**14:55:53** at org.jfrog.hudson.pipeline.common.types.buildInfo.BuildInfo$DeployPathsAndPropsCallable.invoke(BuildInfo.java:386)
**14:55:53** at org.jfrog.hudson.pipeline.common.types.buildInfo.BuildInfo$DeployPathsAndPropsCallable.invoke(BuildInfo.java:362)
**14:55:53** at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3578)
**14:55:53** at hudson.remoting.UserRequest.perform(UserRequest.java:211)
**14:55:53** at hudson.remoting.UserRequest.perform(UserRequest.java:54)
**14:55:53** at hudson.remoting.Request$2.run(Request.java:376)
**14:55:53** at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
**14:55:53** at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
**14:55:53** at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
**14:55:53** at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
**14:55:53** at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:121)
**14:55:53** at java.base/java.lang.Thread.run(Thread.java:1583)
Further digging into the source code of the extension, I found in https://github.com/apache/maven-build-cache-extension/blob/e9fbe3532d16d7fff96340f27da0e0b77aa6b9ff/src/main/java/org/apache/maven/buildcache/CacheControllerImpl.java#L878
the to-be-attached artifact is deleted by deletedOnExit()
I changed temp.toFile().deleteOnExit(); to temp.toFile(); and tested, it worked just fine and the temp artifacts are attached and later deployed to Artifactory even though I actually don't expect those artifacts. I then was able to exclude them by using:
rtMaven.deployer.artifactDeploymentPatterns.addExclude("**mvn-cache**.zip")
---
**Affects:** 1.2.0
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at src/main/java/org/apache/maven/buildcache/CacheControllerImpl.java around line 878 and inspect how attachedOutputs in maven-build-cache-config.xml creates temporary artifacts. Reproduce with the reported Jenkins pipeline, Artifactory plugin, and target/lib configuration; done means the attached artifact remains available when Jenkins constructs build info without causing unintended deployment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100