How to get a status active deployment in Bamboo Edited

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? 

3 answers

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"));
}

Maybe i can get current status tasks in deployment project?

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.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Monday in Confluence

Organizing your space just got easier - Page Tree Drag & Drop is here

Hi Community! I’m Elaine, Confluence Product Manager. You may have read my earlier post about page tree in space navigation sidebar. I'm excited to share another improvement that helps you organize ...

103 views 3 4
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you