public static boolean promoteAndCheckResponse ( Promotion promotion , ArtifactoryBuildInfoClient client , TaskListener listener , String buildName , String buildNumber ) throws IOException { // If failFast is true, perform dry run first if ( promotion . isFailFast ( ) ) { promotion . setDryRun ( true ) ; listener . getLogger ( ) . println ( "Performing dry run promotion (no changes are made during dry run) ..." ) ; HttpResponse dryResponse = client . stageBuild ( buildName , buildNumber , promotion ) ; try { validatePromotionSuccessful ( dryResponse , true , promotion . isFailFast ( ) , listener ) ; } catch ( IOException e ) { listener . error ( e . getMessage ( ) ) ; return false ; } listener . getLogger ( ) . println ( "Dry run finished successfully.\nPerforming promotion ..." ) ; } // Perform promotion promotion . setDryRun ( false ) ; HttpResponse response = client . stageBuild ( buildName , buildNumber , promotion ) ; try { validatePromotionSuccessful ( response , false , promotion . isFailFast ( ) , listener ) ; } catch ( IOException e ) { listener . error ( e . getMessage ( ) ) ; return false ; } listener . getLogger ( ) . println ( "Promotion completed successfully!" ) ; return true ; }
Two stage promotion dry run and actual promotion to verify correctness .