#NEWLINE# def run_ant_target( target , env , config , check_credentials = None ) : #NEWLINE# #INDENT# if check_credentials : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# check_salesforce_credentials ( env ) #NEWLINE# #UNINDENT# except SalesforceCredentialsException as e : #NEWLINE# #INDENT# click . echo ( ( 'BUILD FAILED: %s' % e ) ) #NEWLINE# sys . exit ( 4 ) #NEWLINE# #UNINDENT# #UNINDENT# p = sarge . Command ( ( '%s/ci/ant_wrapper.sh %s' % ( config . cumulusci_path , target ) ) , stdout = sarge . Capture ( buffer_size = ( - 1 ) ) , env = env ) #NEWLINE# p . run ( async = True ) #NEWLINE# log = [ ] #NEWLINE# while ( p . returncode is None ) : #NEWLINE# #INDENT# for line in p . stdout : #NEWLINE# #INDENT# log . append ( line . rstrip ( ) ) #NEWLINE# click . echo ( line . rstrip ( ) ) #NEWLINE# #UNINDENT# p . poll ( ) #NEWLINE# #UNINDENT# if p . returncode : #NEWLINE# #INDENT# logtxt = '\n' . join ( log ) #NEWLINE# try : #NEWLINE# #INDENT# if ( logtxt . find ( 'All Component Failures:' ) != ( - 1 ) ) : #NEWLINE# #INDENT# raise DeploymentException ( logtxt ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( logtxt . find ( '[exec] Failing Tests' ) != ( - 1 ) ) : #NEWLINE# #INDENT# raise ApexTestException ( logtxt ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise AntTargetException ( logtxt ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except DeploymentException as e : #NEWLINE# #INDENT# click . echo ( 'BUILD FAILED: One or more deployment errors occurred' ) #NEWLINE# sys . exit ( 2 ) #NEWLINE# #UNINDENT# except ApexTestException as e : #NEWLINE# #INDENT# click . echo ( 'BUILD FAILED: One or more Apex tests failed' ) #NEWLINE# sys . exit ( 3 ) #NEWLINE# #UNINDENT# except AntTargetException as e : #NEWLINE# #INDENT# click . echo ( 'BUILD FAILED: One or more Ant target errors occurred' ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# #UNINDENT# return p