Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
TAGS
Community showcase
Published in Bamboo

Bamboo 7.1 is here and is packed with value!

I'm happy to announce that Bamboo 7.1 has been released and it’s overflowing with awesome new features. Top-voted issues First and foremost, a bunch of JAC top voted issues has been delivered - y...

653 views 1 6
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you