#NEWLINE# @ click . command ( help = 'Deploys a beta managed package version by its git tag and commit' ) #NEWLINE# @ click . argument ( 'tag' ) #NEWLINE# @ click . argument ( 'commit' ) #NEWLINE# @ click . option ( '--run-tests' , default = False , is_flag = True , help = 'If set, run tests as part of the deployment.  Defaults to not running tests' ) #NEWLINE# @ click . option ( '--retries' , default = 3 , help = 'The number of times the installation should retry installation if the prior attempt failed due to a package unavailable error.  This error is common after uploading a package if the test org is on a different pod.  There is a slight delay in copying newly uploaded packages.  Defaults to 3' ) #NEWLINE# @ pass_config #NEWLINE# def beta_deploy( config , tag , commit , run_tests , retries ) : #NEWLINE# #INDENT# config . sf_username = config . get_env_var ( ( 'SF_USERNAME_' + config . beta_org_suffix ) ) #NEWLINE# config . sf_password = config . get_env_var ( ( 'SF_PASSWORD_' + config . beta_org_suffix ) ) #NEWLINE# config . sf_serverurl = config . get_env_var ( ( 'SF_SERVERURL_' + config . beta_org_suffix ) , config . sf_serverurl ) #NEWLINE# click . echo ( ( 'Building as user %s' % config . sf_username ) ) #NEWLINE# package_version = ( tag . replace ( 'beta/' , '' ) . replace ( '-' , ' ' ) . replace ( 'Beta' , '(Beta' ) . replace ( '_' , ' ' ) + ')' ) #NEWLINE# args = [ config . commit , package_version ] #NEWLINE# if run_tests : #NEWLINE# #INDENT# args . append ( '--run-tests' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# deploy_managed . main ( args = args , standalone_mode = False , obj = config ) #NEWLINE# #UNINDENT# except DeploymentException as e : #NEWLINE# #INDENT# error = repr ( e ) #NEWLINE# if ( ( not retries ) or ( ( error . find ( 'Error: Invalid Package, Details: This package is not yet available' ) == ( - 1 ) ) and ( error . find ( ( 'Error: InstalledPackage version number : %s does not exist!' % package_version ) ) == ( - 1 ) ) ) ) : #NEWLINE# #INDENT# raise retries #NEWLINE# #UNINDENT# click . echo ( ( 'Retrying installation of %s due to package unavailable error.  Sleeping for 1 minute before retrying installation.  %s retries remain' % ( package_version , ( retries - 1 ) ) ) ) #NEWLINE# sleep ( 60 ) #NEWLINE# args = [ tag , commit , '--org' , org , '--retries' , ( retries - 1 ) ] #NEWLINE# if run_tests : #NEWLINE# #INDENT# args . append ( '--runtests' ) #NEWLINE# #UNINDENT# click . echo ( ( 'Retry command: cumulusci ci beta_deploy %s' % ' ' . join ( args ) ) ) #NEWLINE# deploy_beta . main ( args = args , standalone_mode = False )