I am running a process that has a whole directory as output, which I declare as "path".
While the output directory name remains the same every iteration, thus being always found and saved in the publishDir, the content of the directory is not constant. In fact, the directory contains an arbitrary number of files named "pool_1", "pool_2", ... , "pool_n" which are generated by the program, but the numbering depends on the order of completion. Hence, pool_1 could be two different pools in two different runs.
When you declare a path as output, how does publishDir work? Does it overwrite the whole directory each iteration, or does it check if it exists and potentially overwrite the files inside according to their name?