Open AbrilRBS opened 7 months ago
We found that the issue comes from two places:
workspace
has Unix separators, while include
has Windows \
separators, which made the check for include.equals(workspace)
to always fail, regardless of if they are pointing to the same locationC:
drive in the FilePath, and when asking for its parent, an unexpected null was returnedOur current patch looks like this, with which we can upload files:
diff --git a/src/main/java/com/google/jenkins/plugins/storage/util/StorageUtil.java b/src/main/java/com/google/jenkins/plugins/storage/util/StorageUtil.java
index 7dd7e00..fc8d1e0 100644
--- a/src/main/java/com/google/jenkins/plugins/storage/util/StorageUtil.java
+++ b/src/main/java/com/google/jenkins/plugins/storage/util/StorageUtil.java
@@ -41,10 +41,12 @@ public class StorageUtil {
*/
public static String getRelative(FilePath include, FilePath workspace) throws UploadException {
LinkedList<String> segments = new LinkedList<String>();
+ String includePath = include.getRemote();
+ include = new FilePath(include.getChannel(), includePath.replace("\\", "/"));
while (!include.equals(workspace)) {
segments.push(include.getName());
include = include.getParent();
- if (Strings.isNullOrEmpty(include.getName())) {
+ if (include == null || Strings.isNullOrEmpty(include.getName())) {
// When we reach "/" we're done either way.
break;
}
Jenkins and plugins versions report
Environment
Jenkins: 2.440.2 OS: Linux - 5.4.129+ Java: 17.0.10 - Eclipse Adoptium (OpenJDK 64-Bit Server VM) --- google-oauth-plugin:1.330.vf5e86021cb_ec google-storage-plugin:1.360.v6ca_38618b_41f(Note that as per company policy, I have had to trim the plugin list to just the releated ones, let me know if this looks like you could use some more in the list!)
What Operating System are you using (both controller, and any agents involved in the problem)?
Controller is Linux, Agent in Windows Server 2019
Reproduction steps
This small pipeline repro case:
Expected Results
The
hello.txt
file is uploaded to ourfoobar/path
bucketActual Results
I get a
NullPointerException
, with the following stacktrace:Anything else?
The same works for our Linux and Macos agents
Are you interested in contributing a fix?
If I get pointed to the underlying issue, I'd be happy to :)