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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,572 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