I've created custom plugin for Bamboo - task, when I want to search deploy log for result: "Failed" or "Success".
How can i find result status of all tasks in deployment plan while it in progress?
I solved the problem this way - in finally task:
URL url = new URL("http://hostname:8085/rest/api/1.0/deploy/result/" + deploymentTaskContext.getDeploymentContext().getResultKey().getResultNumber(); + "?includeLogs=true");
String user = ""; // username
String pass = ""; // password or API token
String authStr = user + ":" + pass;
String encoding = DatatypeConverter.printBase64Binary(authStr.getBytes("utf-8"));
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setDoOutput(true);
connection.setRequestProperty("Authorization", "Basic " + encoding);
InputStream content = connection.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(content));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line.contains("with result: Failed"));
}
I realize you have identified a solution already, just in case:
The information is a bit buried, but given you are implementing a custom plugin, you might want to check section 'Reading Logs' in the Task overview, which references a dedicated Java interface for log interception at runtime:
We've added infrastructure for analysing build logs on the fly. For documentation, see LogInterceptor. You can add these interceptors to the LogInterceptorStack in the BuildLogger. For examples of usage, see com.atlassian.bamboo.build.logger.interceptors.StringMatchingInterceptor and com.atlassian.bamboo.plugins.ant.task.AntBuildTask .
As hinted upon, you probably need to check the Bamboo source for details on how to use it.
Please note that I'm not aware whether the exact same interface applies to the unfortunately ever so slightly different deployment projects as well, but would at least expect a similar mechanism to be in place there.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Maybe i can get current status tasks in deployment project?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.