Manage Checked Out Publishing Pages (OCDCheckedOutPages StsAdm command)
Structured and repeatable deployment of SharePoint solutions is very important for preserving scalability and maintainability of the solution. Furthermore it allows you to keep track of the deployed components what is very important if you want to provide your customers with support for your solution.
Here at Imtech ICT Velocity we have taken that concept even further and have developed a tool (Imtech SharePoint One Click Deployment Studio - OCD) which allows us to deploy the configuration in a structured and repeatable way. Next to the benefits I have mentioned before, we are able to collaborate not only on assets but on the configuration as well while having separate development environments!
Deploying SharePoint solutions in a structured and repeatable way is not that difficult if well planed. At the end of the day you create a distributable (.wsp) and deploy it to the server.
Deploying SharePoint configuration in a structured and repeatable way has two sides. First of all you will deploy it together with the first release of your SharePoint solution. There are no variable and you’re very likely to deploy it all to a blank environment. Another scenario is deploying the configuration to an existing site - this is comparable to a 1.1 or 2.0 release. The target environment consists of your assets and configuration released previously, content (!) and customization (!).
So far, in all the projects I have worked on, we weren’t removing anything during the configuration deployment vNext. Instead we were either provisioning additional Web Parts or setting some properties. To be able to provision the updates, OCD requires all Publishing Pages to be checked in. Several times already we have experience the contrary. Sure you could instruct the content owners to get sure that there are none, but depending on how big the web site is, this process might get complex and take unnecessary big amount of time. Still, you would need to have a way to ensure that the content owners did their job and there are no checked out Publishing Pages left.
To support the deployment process I have created the OCDCheckedOutPages custom StsAdm command - surprisingly it was one I haven’t found on Gary’s list.
First of all the command allows you to check whether there are any checked out Publishing Pages. If any pages are found, you can use the OCDCheckedOutPages command to either undo the check out, or check pages in in one of the three modes: overwrite, check in as minor version and check in as major version.
The OCDCheckedOutPages command returns different error codes what allows you to make it a part of your batch deployment script. While enumerating the checked out pages, the command returns 0 if no checked out pages found and 1 if there are Publishing Pages checked out.
While managing the checked out pages the command returns a 0 if the checkin/discard checkout were successful and -1 if an exception has been thrown. In all situations the command returns -2 if there was a syntax error while calling the stsadm command.
You could make the OCDCheckedOutPages custom StsAdm command a part of your deployment script as follows:
stsadm -o ocdcheckedoutpages -url %URL% -action enum -verbose
@if ERRORLEVEL 1 goto CheckedOutPagesFound
@if ERRORLEVEL -10 goto End
@echo Checked out pages found.
@Choice /C:CDOIM /T:10 /D:c /M:"Choose one of the following options: (c)ancel (d)iscard (o)verwrite m(i)nor (m)ajor"
@if ERRORLEVEL 2 goto ocdcheckedoutpages
@if ERRORLEVEL 5 SET OPTION=major
@if ERRORLEVEL 4 SET OPTION=minor
@if ERRORLEVEL 3 SET OPTION=overwrite
@if ERRORLEVEL 2 SET OPTION=discard
stsadm -o ocdcheckedoutpages -url %URL% -action %OPTION% -verbose
@if ERRORLEVEL 0 goto End
exit /B -1
First of all you run a check if there are any checked out Publishing Pages (1). If any checked out pages have been found (2) you display a message (6) and prompt the user which action should be run (11). Depending on the choice you either cancel the deployment process (16, 27), discard the checkout (22) or check the pages in (15, 19-24).
In many situations you are very likely to run the deployment process unattended. In such situation waiting for the user to choose the desired action would have undesired results. That is why I have chosen to set the choice timeout to 10 seconds (11, /T:10). If the user won’t choose any option in 10 seconds, the default choice - cancel (11, /D:c) will be taken. Depending on the agreements with your customer you might want to change this to discard (/D:D) or check in draft (/D:I).
OCDCheckedOutPages is a free StsAdm command and you can use it without any restrictions.
Download: OCDCheckedOutPages (6KB)