def print_build_status(build): print(" Status: %s" % get_new_status(build)) print(" Url: %s " % get_url(build)) if(build.has_resultset()): print(" Test count: %s" % get_total_count(build)) print(" Test failures: %s" % get_fail_count(build)) for case in get_test_cases(build): if(case['status'] == "REGRESSION"): print(" Failure: %s" % case['className'])
def action_trigger_build(job, source, target, dryrun): original_build_no = job.get_last_buildnumber() params_block = False # done manually print "Triggering a new build for " + source + " -> " + target + " :" try: job.invoke(block=params_block, build_params={'SourceBranch': source, 'TargetBranch': target, 'dryrun': str(dryrun).lower(), 'delay': '0sec'}) except HTTPError as e: exit_with_error( "HTTPError while triggering the build. Please verify your parameters (job: %s, source: %s, target: %s). Cause :%s" % ( job, source, target, e.msg)) block_until_build_started(job, source, original_build_no) build = job.get_last_build() count = 0 fail_notified = False while build.is_running(): status = get_new_status(build) total_wait = BUILD_CHECK_DELAY * count fail_count = get_fail_count(build) if fail_count > 0 and not fail_notified: notify("Build #" + str(build.get_number()), str("Test failures : %s" % fail_count)) fail_notified = True print "Build #%s (%s) is %s. Test failures : %s. Started %im ago." % ( build.get_number(), get_url(build), status, fail_count, total_wait / 60) sleep(BUILD_CHECK_DELAY) count += 1 pass sleep(JENKINS_LAG_DELAY) print_build_status(build) notify("Build #" + str(build.get_number()), str(get_new_status(build)))