Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Is there an easy way to get a report on Bamboo Agent's idle time

Is the below script runner based Bamboo core JAVA API call still the best way to get this report?


import com.atlassian.bamboo.resultsummary.AgentResultsSummaryManagerimport com.atlassian.bamboo.resultsummary.BuildResultsSummaryimport com.atlassian.bamboo.util.TextProviderUtilsimport com.atlassian.bamboo.utils.DurationUtilsimport com.atlassian.sal.api.component.ComponentLocatorimport groovy.transform.BaseScript import java.util.concurrent.TimeUnit @BaseScript CustomEndpointDelegate delegate /** * End point to retrieve Bamboo agent build activity details. * * @return Response wrapping build activity details */ getAgentActivityDetails(httpMethod: "GET", groups: ["bamboo-admin"]) {    MultivaluedMap queryParams, String body ->        RequestParams requestParams = RequestParams.from(queryParams);        AgentActivityDetailsDto agentActivityDetialsDto = doGetAgentActivityDetialsDto(requestParams)        return Response.ok(agentActivityDetialsDto).build()} /** * Implementation for retrieving Bamboo agent's activity details. * * @Param params from request. * @return Agent activity details wrapped in an object. * */def doGetAgentActivityDetialsDto(RequestParams params) {    def AgentActivityDetailsDto agentActivityDetialsDto = new AgentActivityDetailsDto();    def AgentResultsSummaryManager agentManager = ComponentLocator.getComponent(AgentResultsSummaryManager)    List<BuildResultsSummary> allBuildsSummary = agentManager.getAllBuildResultsSummariesForAgent(params.agentId)    def long totalQueueDuration = 0L    def long totalDuration = 0L    def long totalProcessingDuration = 0L    def long reportingDaysMills = TimeUnit.DAYS.toMillis(params.reportingDays)    def long idleMillis = reportingDaysMills - totalProcessingDuration      allBuildsSummary.each {        buildSummary ->            long duration = buildSummary.duration            long queueDuration = buildSummary.queueDuration            long processingDuration = buildSummary.processingDuration            totalQueueDuration += queueDuration            totalProcessingDuration += processingDuration            totalDuration += duration    }     agentActivityDetialsDto.setTotalBuildsCount(allBuildsSummary.size())    agentActivityDetialsDto.setIdleTime(formatMillisToTime(idleMillis))    agentActivityDetialsDto.setTotalProcessingDuration(formatMillisToTime(totalProcessingDuration))    agentActivityDetialsDto.setTotalDuration(formatMillisToTime(totalDuration))    agentActivityDetialsDto.setTotalQueueDuration(formatMillisToTime(totalQueueDuration))     return agentActivityDetialsDto} /** * Formats time in milli second to pretty printing in minutes. * * @Param millis * @return pretty time * */def String formatMillisToTime(long millis) {    double processingDuration = (double) millis;    return processingDuration > 0.0D ? DurationUtils.getPrettyPrint((long) processingDuration) : TextProviderUtils            .getText("global.unknown"); } class AgentActivityDetailsDto {    int totalBuildsCount;    String idleTime;    String totalDuration;    String totalQueueDuration;    String totalProcessingDuration} class RequestParams {    int agentId;    int startPage;    int pageSize;    int reportingDays;     static RequestParams from(MultivaluedMap queryParams) {        RequestParams requestParams = new RequestParams();        requestParams.setAgentId(queryParams.get("agentId"))        requestParams.setReportingDays(queryParams.get("reportingDays"))        requestParams.setStartPage(queryParams.get("startPage"))        requestParams.setPageSize(queryParams.get("pageSize"))        return requestParams    }}

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bamboo

Bamboo 101 Video

G’day Community! As we gear up to introduce Bamboo Data Center to the world, we wanted to make sure that we shared a bit more about Bamboo, the product. Our team has put together an overview video ...

222 views 4 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