Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-70622] Do not remove temporary Unix files #24

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 0 additions & 36 deletions src/main/java/org/jenkinsci/plugins/slave_setup/Components.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;

import hudson.AbortException;
import hudson.EnvVars;
Expand Down Expand Up @@ -249,7 +248,6 @@ public static boolean doConfigSetups(List<Computer> activeSlaves) {
try {
Components manager = new Components(slave);
manager.doConfig();
manager.clearTemporally();
} catch (Exception ex) {
Components.info(String.format("Failed to configure %s%nErr:%s", slave.getName(), ex.getMessage()));
succeded = false;
Expand All @@ -275,7 +273,6 @@ public static boolean doSetups(List<Computer> activeSlaves) {
try {
Components manager = new Components(slave);
manager.doSetup();
manager.clearTemporally();
} catch (Exception ex) {
Components.info(String.format("Failed to configure %s%nErr:%s", slave.getName(), ex.getMessage()));
succeded = false;
Expand Down Expand Up @@ -316,39 +313,6 @@ private void doDeploy(SetupConfigItem installInfo) throws IOException, Interrupt
this.addCache(installInfo.remoteCache());
}

/**
* Only works on Unix Operating Systems, this will use some unix commands to
* clear temporally data
*
* If file has more than 5 minutes in the last modified tag, it will be removed.
* Only will remove files which name is jenkins
*
* This function require at least (find) binary to be installed
*
* @throws InterruptedException Broken pipe.
* @throws IOException IO error accessing remotePath
* @throws AbortException User close/Cancelled
*
*/
public void clearTemporally() throws AbortException, IOException, InterruptedException {

String clearTmp = "find /tmp -type f -atime +10 -delete -iname *jenkins*.sh -maxdepth 0";
EnvVars environ = SetupDeployer.createEnvVarsForComputer(this.slave);

if (this.remotePath.getRemote().startsWith("/")) {
// Clear slave temporally data
Components.info("Clearing temporally data on " + this.slave.getName());
validateResponse(Utils.multiOsExecutor(Components.listener, clearTmp, this.remotePath, environ));
}

if (SystemUtils.IS_OS_UNIX) {
// Clear master temporally data
Components.info("Clearing temporally data on jenkins master");
validateResponse(SetupDeployer.executeScriptOnMaster(Components.listener, clearTmp, environ));
}
Components.debug("Finished temporal data removed");
}

/**
* Validate execution scripts code, in order to throw exception if not
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public void preOnline(Computer c, Channel channel, FilePath root, TaskListener l

manager.doSetup();
Components.debug("Setup Ended");

manager.clearTemporally();
}

}