Skip to content

Commit

Permalink
Merge branch 'release/v1.5.5' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Robirosa committed Nov 6, 2023
2 parents 8d54c03 + 4f92ab0 commit c3173f3
Show file tree
Hide file tree
Showing 67 changed files with 329 additions and 466 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/arobirosa.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
classprefix="ArecoDeploymentScriptsExamples"
managername="ArecoDeploymentScriptsExamplesManager"
managersuperclass="de.hybris.platform.jalo.extension.Extension"
jaloLogicFree="true"
>
<requires-extension name="arecoDeploymentScriptsManager" />
<!-- The reload cockpit configuration examples uses de.hybris.platform.cockpit.systemsetup.CockpitImportConfig -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.5.4
version=1.5.5

This file was deleted.

This file was deleted.

51 changes: 3 additions & 48 deletions hybris/bin/custom/arecoDeploymentScriptsManager/buildcallbacks.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
<?xml version="1.0"?>
<project name="arecoDeploymentScriptsManager_buildcallbacks" >

<macrodef name="deploymentScriptsLoggingStart">
<sequential>
<record action="start" append="true" name="${HYBRIS_LOG_DIR}/deploymentScripts.log" loglevel="debug" />
</sequential>
</macrodef>

<macrodef name="deploymentScriptsLoggingEnd">
<sequential>
<record action="stop" append="false" name="${HYBRIS_LOG_DIR}/deploymentScripts.log" loglevel="debug" />
</sequential>
</macrodef>

<macrodef name="checkIfTheDeploymentScriptsWereSuccessful">
<sequential>
<yrun failonerror="true">
import de.hybris.platform.core.Registry;
import org.areco.ecommerce.deploymentscripts.ant.AntDeploymentScriptsStarter;

AntDeploymentScriptsStarter starter = (AntDeploymentScriptsStarter) Registry.getApplicationContext().getBean(AntDeploymentScriptsStarter.class);
boolean wasLastScriptSuccessful = starter.wasLastScriptSuccessful();
de.hybris.platform.util.RedeployUtilities.shutdown();
System.exit(wasLastScriptSuccessful ? 0 : 1);
starter.stopAntBuildIfTheLastScriptFailed();
</yrun>
</sequential>
</macrodef>
Expand All @@ -41,35 +26,18 @@
DataCreatorAndDeploymentScriptsStarter dataCreator = (DataCreatorAndDeploymentScriptsStarter) Registry.getApplicationContext().getBean(DataCreatorAndDeploymentScriptsStarter.class);

dataCreator.runInJunitTenant();
boolean wasLastScriptSuccessful = starter.wasLastScriptSuccessful();
de.hybris.platform.util.RedeployUtilities.shutdown();
System.exit(wasLastScriptSuccessful ? 0 : 1);
starter.stopAntBuildIfTheLastScriptFailed();
</yrun>
<deploymentScriptsLoggingEnd />
</sequential>
</macrodef>

<!-- Logging during the update running system -->
<macrodef name="arecoDeploymentScriptsManager_before_updatesystem">
<sequential>
<deploymentScriptsLoggingStart />
</sequential>
</macrodef>

<macrodef name="arecoDeploymentScriptsManager_after_updatesystem">
<sequential>
<deploymentScriptsLoggingEnd />
<checkIfTheDeploymentScriptsWereSuccessful />
</sequential>
</macrodef>

<!-- Logging during the initialization -->
<macrodef name="arecoDeploymentScriptsManager_before_initialize">
<sequential>
<deploymentScriptsLoggingStart />
</sequential>
</macrodef>

<macrodef name="arecoDeploymentScriptsManager_after_initialize">
<sequential>
<if>
Expand All @@ -78,24 +46,15 @@
<initializeJunitTenant />
</then>
<else>
<deploymentScriptsLoggingEnd />
<checkIfTheDeploymentScriptsWereSuccessful />
</else>
</if>
</sequential>
</macrodef>

<!-- Logging during the initialization of the junit tenant. -->
<macrodef name="arecoDeploymentScriptsManager_before_yunitinit">
<sequential>
<deploymentScriptsLoggingStart />
</sequential>
</macrodef>

<macrodef name="arecoDeploymentScriptsManager_after_yunitinit">
<sequential>
<initializeJunitTenant />
<deploymentScriptsLoggingEnd />
</sequential>
</macrodef>

Expand All @@ -107,18 +66,14 @@
import org.areco.ecommerce.deploymentscripts.ant.AntDeploymentScriptsStarter;

AntDeploymentScriptsStarter starter = (AntDeploymentScriptsStarter) Registry.getApplicationContext().getBean(AntDeploymentScriptsStarter.class);
int exitCode = starter.runPendingScripts();
de.hybris.platform.util.RedeployUtilities.shutdown();
System.exit(exitCode);
starter.runPendingScriptsAndThrowExceptionIfThereWasAnError()
</yrun>
</sequential>
</macrodef>

<target name="runDeploymentScripts" description="Runs all pending deployment scripts without requiring an update running system">
<sequential>
<deploymentScriptsLoggingStart />
<runDeploymentScripts/>
<deploymentScriptsLoggingEnd />
</sequential>
</target>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
classprefix="ArecoDeploymentScriptsManager"
managername="ArecoDeploymentScriptsManagerManager"
managersuperclass="de.hybris.platform.jalo.extension.Extension"
jaloLogicFree="true"
>

<coremodule packageroot="org.areco.ecommerce.deploymentscripts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ deploymentscripts.init.folder = init-deployment-scripts
deploymentscripts.init.junittenant.createessentialdata = true
deploymentscripts.init.junittenant.createprojectdata=true

#When a deployment script fails, does the deployment manager stop the ant process?
deploymentscripts.stopantonerror=true

#Locale used to import the impex files.
deploymentscripts.impex.locale = en_US

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,12 @@
scope="tenant">
<lookup-method name="newDeploymentScript" bean="deploymentScript" />
</bean>

<!-- Every time the step factory is called, it creates a new instance. -->
<bean id="propertyFileDeploymentScriptConfiguration" scope="prototype"
class="org.areco.ecommerce.deploymentscripts.core.impl.PropertyFileDeploymentScriptConfiguration" />

<alias name="arecoLocalizedImpexService" alias="impexImportService" />
<bean id="arecoLocalizedImpexService" class="org.areco.ecommerce.deploymentscripts.impex.impl.LocalizedImpexImportService"
scope="tenant"/>
</beans>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.5.4
version=1.5.5
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.areco.ecommerce.deploymentscripts.ant;

import de.hybris.platform.servicelayer.config.ConfigurationService;
import de.hybris.platform.servicelayer.session.SessionExecutionBody;
import de.hybris.platform.servicelayer.session.SessionService;
import de.hybris.platform.servicelayer.user.UserService;
Expand All @@ -36,6 +37,8 @@
@Service("antDeploymentScriptsStarter")
@Scope("tenant")
public class AntDeploymentScriptsStarter {
public static final String STOP_ANT_ON_ERROR_CONF = "deploymentscripts.stopantonerror";

private static final Logger LOG = LoggerFactory.getLogger(AntDeploymentScriptsStarter.class);

@Autowired
Expand All @@ -47,12 +50,37 @@ public class AntDeploymentScriptsStarter {
@Autowired
private SessionService sessionService;

@Autowired
private ConfigurationService configurationService;

/**
* Run any deployment script which wasn't run yet. Depending on the configuration, throw an exception to stop the build process if there
* was an error.
*
* @throws DeploymentScriptFailureException if there was an error and the build process must be stopped
*/
public void runPendingScriptsAndThrowExceptionIfThereWasAnError() {
if (this.runPendingScripts()) {
return;
}
throwExceptionToStopAntBuildOrLogMessage("There were errors running the deployment scripts. Check the logs");
}

private void throwExceptionToStopAntBuildOrLogMessage(final String message) {
if (configurationService.getConfiguration().getBoolean(STOP_ANT_ON_ERROR_CONF, true)) {
throw new DeploymentScriptFailureException(message);
}
if (LOG.isDebugEnabled()) {
LOG.debug("There were errors but the ant process must continue. {}", message);
}
}

/**
* Run any deployment script which wasn't run yet. The method is called by the ant script.
*
* @return 0 if everything went ok.
* @return true if everything went ok.
*/
public int runPendingScripts() {
private boolean runPendingScripts() {
if (LOG.isInfoEnabled()) {
LOG.info("Running any pending UPDATE deployment scripts.");
}
Expand All @@ -65,20 +93,23 @@ public Object execute() {

if (wasThereAnError) {
LOG.error("There was an error running the deployment scripts. Please check the console.");
return 1; // Error
return false; // Error
}
if (LOG.isInfoEnabled()) {
LOG.info("All pending scripts were run successfully.");
}
return 0;
return true;
}

/**
* Check if the last executed deployment scripts was successful.
* Check if the last executed deployment script had an error and throw an exception if the ant build must be stopped.
*
* @return true if the last deployment script was successful.
* @throws DeploymentScriptFailureException if there was an error and the build process must be stopped
*/
public boolean wasLastScriptSuccessful() {
return this.deploymentScriptStarter.wasLastScriptSuccessful();
public void stopAntBuildIfTheLastScriptFailed() {
if (this.deploymentScriptStarter.wasLastScriptSuccessful()) {
return;
}
throwExceptionToStopAntBuildOrLogMessage("The last deployment script failed");
}
}
Loading

0 comments on commit c3173f3

Please sign in to comment.