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.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 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
Published Wednesday in Jira

Make your Atlassian Cloud products more secure: our NEW admin security guide

Hey admins! I’m Dave, Principal Product Manager here at Atlassian working on our cloud platform and security products. Cloud security is a moving target. As you adopt more products, employees consta...

142 views 0 6
Read article

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