We are deleting logs and ARTIFACTS. Quick Build supports its own, but it does not match the settings we want, so we are writing it as an internal GROOVY SCRIPT and deleting it.
However, loading one that has 450,000 builds will overload the CPU and crash the system.
We have been working to resolve this. One solution is to look up the object to be deleted in the DB, load the objects to be deleted one by one, retrieve the locations of PUBDIRECTORY and ARTIFACTS, and then delete them.
However, this was not a perfect solution, so an attempt was made to artificially make the task work on only one THREAD.
However, in the inner script, "ExecutorService executorService = Executors.newSingleThreadExecutor();" When you write a program, the executorService value returns NULL, so you cannot write a program that uses one THREAD. However, if you change the step to "Build > Shell/Batch Command" and execute it by giving a command like "groovy /root/test.groovy", the executorService value returns as normal, so THREAD programming appears to be possible.
---------------- SAMPLE CODE (Misc > Execute Script) --------------
groovy:
import com.pmease.quickbuild.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
Runnable run = {
def db2 = groovy.sql.Sql.newInstance("jdbc:mysql://localhost:3306/quickbuild","root","YOUR PASSWD","com.mysql.jdbc.Driver");
List foodList = db2.rows('select * from QB_BUILD');
foodList.each{ row -> System.out.println(row.QB_ID) }
}
ExecutorService executorService = Executors.newSingleThreadExecutor();
logger.info("{}", System.out.println(executorService));
executorService.execute(run);
executorService.awaitTermination(10, TimeUnit.SECONDS);
executorService.shutdown();
<<< RESULT LOG >>>>.
18:57:31,138 INFO - Executing pre-execute action...
18:57:31,138 INFO - Running step...
18:57:31,156 INFO - null <<====== TRHEAD NULL RETURN
18:57:41,157 INFO - Executing post-execute action...
THREAD must be used, and for this, it must be executed in the "Shell/Batch Command" method, but it was said that the system class is not supported in external script execution, so I tried to learn about PUBDIRECTORY and ARTIFACTS in the REST API.
When I set the step to "Misc > Execute Script" and use THREAD, "ExecutorService executorService = Executors.newSingleThreadExecutor();" returns null when I use this syntax. Is this intended in quickbuild? Or is there another way?