Emergency publish - publish during a publish

  • Add items into the current publishing job even after it has started.
  • Publish emergency content whilst another publish is running.

We have content editors who just love to publish! - the Publish Queue is always full. There are many strategies to improve this - workflow, scheduled publishing and tweaking the current working process are just a few examples.

However, with our current process if we need to get some emergency content live immediately (legal reasons for example) we can't. We could cancel all the current publish jobs (https://marketplace.sitecore.net/Modules/AdvancedPublishDialog.aspx?sc_lang=en) perhaps but that is far from ideal.

I tried a few things, dual publishing instances and using PublishManager to programatically inject items into the queue but the best way to achieve this was devised by our good friends at Sitecore support (in particular Andrey).

Below is the code, you can easily use Sitecore's security mechnism to lock down the Emergency publish button to specific roles.


public class EmergencyPublish : PublishItemProcessor 
    internal static List<Item> EmergencyPublishList = new List<Item>();

    public override void Process(PublishItemContext context)
        lock (EmergencyPublishList)
            foreach (Item item in EmergencyPublishList)

                    PublishOptions options = new PublishOptions(context.PublishOptions.SourceDatabase, context.PublishOptions.TargetDatabase, PublishMode.SingleItem, item.Language, context.PublishOptions.PublishDate)
                        ChildComparer = context.PublishOptions.ChildComparer,
                        CompareRevisions = context.PublishOptions.CompareRevisions,
                        Deep = false,
                        FromDate = context.PublishOptions.FromDate
                    options.Mode = PublishMode.SingleItem;
                    options.Replacer = context.PublishOptions.Replacer;
                    options.RepublishAll = context.PublishOptions.RepublishAll;

                    context.Result.ReferredItems.Add(new PublishingCandidate(item.ID, options));


public class EmergencyPublishCommand : Command
    public override void Execute(CommandContext context)
        Sitecore.Diagnostics.Log.Info("Emergency Publish clicked", this);

        if (JobManager.IsJobRunning("Publish to 'web'"))
            Item item = context.Items[0];
            if (item != null)
                lock (EmergencyPublish.EmergencyPublishList)


<command name="my:emergencyPublish"  type="MyWebsite.EmergencyPublishCommand, MyWebsite" />


Open the Website/Web.config file and insert your processor before:

<processor type="Sitecore.Publishing.Pipelines.PublishItem.MoveItems, Sitecore.Kernel" />


<processor type="Namespace.YourProcessorClass, AssemblylName" />

Core database:

Create item of template Large Menu Combo Button here /sitecore/content/Applications/Content Editor/Ribbons/Chunks/Publish/Emergency Publish

Set the Click field text to: my:emergencypublish

Emergency publish

Dave Leigh

Web, and long time Sitecore developer based in Bristol, UK, working at Valtech - valtech.co.uk - @valtech.
I occasionally do other things too.