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

Fix remote agent PostBuildAction failure #15

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/main/java/org/jfrog/bamboo/JfTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.atlassian.plugin.PluginAccessor;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.codehaus.plexus.util.FileUtils;
import org.jetbrains.annotations.NotNull;
import org.jfrog.bamboo.config.ServerConfig;
import org.jfrog.bamboo.config.ServerConfigManager;
Expand Down Expand Up @@ -102,7 +103,7 @@ public class JfTask extends JfContext implements TaskType {
buildLog.error(ExceptionUtils.getRootCauseMessage(e), e);
return resultBuilder.failedWithError().build();
}
return resultBuilder.success().build();
return cleanUpTask(resultBuilder);
}

/**
Expand Down Expand Up @@ -186,6 +187,24 @@ private int configAllJFrogServers() throws IOException, InterruptedException {
return exitCode;
}

/**
* Removes the JFrog temporary directory that was previously created.
* This function is intentionally not part of the PostBuildAction
* because it lacks the necessary permissions to delete the directory
* when the build is executed on a remote agent.
*
* @return TaskResult status indicating the success of the cleanup.
*/
private @NotNull TaskResult cleanUpTask(TaskResultBuilder resultBuilder) {
try {
FileUtils.deleteDirectory(BambooUtils.getJfrogTmpDir(customVariableContext));
return resultBuilder.success().build();
} catch (IOException e) {
buildLog.error("Failed to delete JFrog temporary directory: " + e.getMessage());
return resultBuilder.failedWithError().build();
}
}

/**
* Runs the 'jf config add' command to configure the server.
*
Expand Down
49 changes: 0 additions & 49 deletions src/main/java/org/jfrog/bamboo/PostBuildAction.java

This file was deleted.

Loading