Tuesday, 28 January 2025

Write deployer extension for Tridion Sites 10

 To Write deployer extension for Tridion Sites with following steps

  1. Create a custom step class which implements "ExecutableStep" (com.sdl.delivery.deployer.api.processing.pipeline.ExecutableStep) interface
    • interface is available on udp-deployer-api-x.x.x-xxxx.jar which can be found on maven repo or in the deployer service installation directory.
  2. Override methods in CustomStep class
    • configure
      @Override
      public void configure(Configuration configuration) throws ConfigurationException {
      //this is section where we initialize step
      }
    • process
      @Override
      public ExecutableStepResult process(ProcessingContext processingContext, StepDataProvider stepDataProvider) throws ProcessingException {
      LOG.debug("Starting ExampleExtension");
      var location = getPackageUnzipLocation(processingContext, stepDataProvider);
      LOG.debug("ExampleExtension getPackageUnzipLocation location {}", location);
      TransportPackage transportPackage = new TransportPackage(location, stepDataProvider.getBinaryStorage());
      LOG.debug("ExampleExtension transportPackage {}", transportPackage);
      final String action = transportPackage.getAction();
      LOG.debug("PageStateNotifier action {}", action);
      final String transactionId = transportPackage.getTransactionId().toString();
      LOG.debug("Process Action {} for Transaction {}", action, transactionId);
      switch (action) {
      case DEPLOY_ACTION:
      LOG.info("Publish action triggerred");
      break;
      case UNDEPLOY_ACTION:
      LOG.info("UnPublish action triggerred");
      break;
      default:
      LOG.error("Invalid action {}", action);
      throw new ProcessingException("Invalid transport package action " + action);
      }
      return null;
      }
  3. Write a spring configuration
    • configuration class should be on package "com.sdl.delivery.spring.configuration"
    • Let's name it ExampleConfiguration
      package com.sdl.delivery.spring.configuration;

      import org.springframework.context.annotation.ComponentScan;
      import org.springframework.context.annotation.Configuration;

      @Configuration
      @ComponentScan(basePackages = {"org.rws.example"})
      public class ExampleConfiguration {
      }
    • above class allows your deployer extension to be developed on specific package for example in above ExampleConfiguration it scans package "org.rws.example" then you can implement your CustomStep on step 1 inside package "org.rws.example".
  4. Please also include following minimum java libraries for development of Tridion Sites deployer extension
    • udp-common-config-api-x.x.x-xxxx.jar
    • udp-common-config-x.x.x-xxxx.jar
    • udp-common-util-x.x.x-xxxx.jar
    • udp-core-x.x.x-xxxx.jar
    • udp-data-legacy-transport-x.x.x-xxxx.jar
    • udp-deployer-api-x.x.x-xxxx.jar
    • udp-deployer-web-extension-x.x.x-xxxx.jar
  5. x.x.x-xxxx denotes version of api available on installation directory of deployer service.
  6. After creating CustomStep, based on your project setup (i.e. maven or gradle) configure build steps which could generate a add-on package file in zip.
  7. zip file contains generated jar file and dependent jars those are not available on deployer service libraries, and manifest file requires for Addon service to specify type of Add-on.
  8. you can refer maven project which is having build step to generate Addon-package https://github.com/neeteshnarvaria/deployer-extension/blob/master/pom.xml
  9. example maven project generates example-deployer-extension.zip
  10. after all the steps we need to configure/update deployer-conf.xml
    • open in notepad and add custom pipeline after following pipelines, specifically after highlighted one in screenshot below
    • custom pipeline
      <Pipeline Id="Tridion-Example-Step" Action="Deploy,Undeploy" Verb="Process">
      <Steps>
      <Step Id="ExampleExtension" />
      </Steps>
      </Pipeline>
  11. after configuring/update deployer-conf.xml save and close the file.
  12. add the generated package on add-on using upload
  13. select add-on
  14. after upload on add-on it will show as "Pending State"
  15. We need to restart deployer service to activate the deployer extension add-on.
  16. Deployer status should show "Success".
  17. it is ready to use and we can check functionality by adding some logs.

Refer following git repo which contains sample deployer extension having custom step: https://github.com/neeteshnarvaria/deployer-extension