print("Start analyzing the {} projects".format(len(projects)))
    for project in projects:
        print("Inspecting {} project".format(project))
        plans = get_plans_from_project(project)
        print("Start analyzing the {} plans".format(len(plans)))
        for plan in plans:
            print("Inspecting {} plan".format(plan))
            build_results = [
                x for x in bamboo.results(plan_key=plan,
                                          label=LABEL,
                                          max_results=100,
                                          include_all_states=True)
            ]
            for build in build_results:
                build_key = build.get('buildResultKey') or None
                print("Inspecting {} build".format(build_key))
                build_value = bamboo.build_result(build_key)
                build_complete_time = build_value.get(
                    "buildCompletedTime") or None
                if not build_complete_time:
                    continue
                datetimeObj = datetime.strptime(
                    build_complete_time.split('+')[0] + "000",
                    '%Y-%m-%dT%H:%M:%S.%f')
                if datetime.now() > datetimeObj + timedelta(days=OLDER_DAYS):
                    print("Build is old {} as build complete date {}".format(
                        build_key, build_complete_time.strftime("%Y-%m-%d")))
                    if not DRY_RUN:
                        print("Removing {} build".format(build_key))
                        bamboo.delete_build_result(build_key)
# for project in bamboo.projects():
#    print(project)


for branch in bamboo.plan_branches('PROJ-SP2'):
    print(branch)

# for result in bamboo.latest_results():
#    print(result)

# for result in bamboo.plan_results(project_key='FOO', plan_key='BAR'):
#    print(result)

# for report in bamboo.reports():
#    print(report)


# Methods in singular (project, plan, result...) return a single dictionary

print(bamboo.project('FOO'))

print(bamboo.build_result('FOO-BAR-1'))







Beispiel #3
0
ATLASSIAN_USER = os.environ.get('ATLASSIAN_USER', 'admin')
ATLASSIAN_PASSWORD = os.environ.get('ATLASSIAN_PASSWORD', 'admin')

bamboo = Bamboo(url=BAMBOO_URL,
                username=ATLASSIAN_USER,
                password=ATLASSIAN_PASSWORD)

# Methods in plural (projects, plans, results...) return a generator that iterates through
# all results without the need of dealing need with pagination

# for project in bamboo.projects():
#    pprint(project)

for branch in bamboo.plan_branches('PROJ-SP2'):
    pprint(branch)

# for result in bamboo.latest_results():
#    pprint(result)

# for result in bamboo.plan_results(project_key='FOO', plan_key='BAR'):
#    pprint(result)

# for report in bamboo.reports():
#     pprint(report)

# Methods in singular (project, plan, result...) return a single dictionary

pprint(bamboo.project('FOO'))

pprint(bamboo.build_result('FOO-BAR-1'))
Beispiel #4
0
ATLASSIAN_USER = os.environ.get("ATLASSIAN_USER", "admin")
ATLASSIAN_PASSWORD = os.environ.get("ATLASSIAN_PASSWORD", "admin")

bamboo = Bamboo(url=BAMBOO_URL,
                username=ATLASSIAN_USER,
                password=ATLASSIAN_PASSWORD)

# Methods in plural (projects, plans, results...) return a generator that iterates through
# all results without the need of dealing need with pagination

# for project in bamboo.projects():
#    print(project)

for branch in bamboo.plan_branches("PROJ-SP2"):
    print(branch)

# for result in bamboo.latest_results():
#    print(result)

# for result in bamboo.plan_results(project_key='FOO', plan_key='BAR'):
#    print(result)

# for report in bamboo.reports():
#    print(report)

# Methods in singular (project, plan, result...) return a single dictionary

print(bamboo.project("FOO"))

print(bamboo.build_result("FOO-BAR-1"))