Publishing Service: BulkPublishingEnd pipeline

Sitecore Publishing Service replaces the existing Sitecore publishing methods with a faster, reliable and user-friendly solution. It reduces the amount of time spent publishing large volumes of items and provides better visual feedback to the user. It was released for Sitecore 8.2 and is also available for Sitecore 9.

In this post, I am going to write about the publishEndResultBatch pipeline. An event pipeline that Sitecore starts after Sitecore Publishing Service finishes publishing each batch of items.

You can find more information about installing and configuring Sitecore Publishing Service on Sitecore documentation. Also, I recommend you reading Jonathan Robbins blog post Sitecore Publishing Service – Setting up 8.2s new Publishing option.

The publishEndResultBatch pipeline

At the end of a publishing, Sitecore Publishing Service passes the results to the publishEndResultBatch pipeline. Developers can hook into this pipeline to work with these results. You can update site maps with the publishing results, for example, or automatically send an email whenever something goes wrong.

In order to hook into the publishEndResultBatch pipeline, firstly you have to create a class with a method named Process taking PublishEndResultBatchArgs as parameter.

The PublishEndResultBatchArgs is available at the Sitecore.Publishing.Service.Pipelines.BulkPublishingEnd namespace from Sitecore.Publishing.Service.dll.

Here is a sample code.

using Sitecore.Publishing.Service.Pipelines.BulkPublishingEnd;
namespace Sandbox
public class PersistEndResultBatch
public void Process(PublishEndResultBatchArgs args)

You can find the Sitecore.Publishing.Service.dll in the Sitecore Publishing Module 3.1.0 rev. installation package. There is no Nuget package available for this assembly by the time I wrote this post.

Next, you have add the following patch to a configuration file in your project.

<configuration xmlns:patch="; xmlns:set=""&gt;
<processor type="Sandbox.PersistEndResultBatch, Sandbox"
patch:after="*[@type='Sitecore.Publishing.Service.Pipelines.BulkPublishingEnd.RaiseRemoteEvents, Sitecore.Publishing.Service']" >

Sending email after a publishing job is finished

Here is a sample code for sending email. Read the next section for more details about the PublishEndResultBatchArgs.

sample code with PublishEndResultBatchArgs (scaled)
Figure 1: Sample code for sending email after a publishing job is finished

What should you know about PublishEndResultBatchArgs?

The args.JobData member provides you with an overview of the publishing job. Here is some of the information you can get out of JobData property.

  • JobId is a unique identifier for the job. A job can contain one or more batches.
  • LanguageNames shows one or more target publishing languages. Before starting publish job, you select the target languages you want to publish.
  • Metadata contains more options related to the publishing job such as username, publishing targets, clear caches (true/false), the type of publishing (full publish, publish item), include descendants (true/false), etc.
  • Other useful members are PublishDate, SourceDatabaseName (usually “master”), status (Complete, Failed, Cancelled, etc).

The args.Batch members gives you information about the published items. From that you can get the item’s ID through the EntityId property, for example. Also you can identify whether that item was added, changed or deleted.

args.Batch members
Figure 2: args.Batch members

Important! When you add a new version to an item, it will show twice in the args.Batch. One as a deleted item, another as a created item.

PublishEndResultBatchArgs when a version is created (edited)
Figure 3: args.Batch when a version is added to an item

That is why I use the code snippet below to select unique items and count them.

var itemsAffected =
    args.Batch.Select(b => b.EntityId).Distinct().Count();

In this post, I briefly described what you can do with the BulkPublishingEnd event pipeline and some information and heads up on the PublishEndResultBatchArgs.

You can find the sample code for sending email on my GitHub repository.

2 thoughts on “Publishing Service: BulkPublishingEnd pipeline

  1. Have yo made a request to the support to include the publishing service in the nuget feed? If not you may want to use the same ref number: Reply from support: “I registered the appropriate wish to add the Publishing Service to the NuGet feed.
    To track the future status of this wish, please use the reference number 288832.”

    Liked by 1 person

    1. Hi Erik. I haven’t requested them to include the publishing service in the nuget feed. Thanks for sharing the reference number. It would be nice having those in nuget.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s