Create a page with lots of revisions

Last modified by Nikita Petrenko on 2026/06/02 17:55

cogCreates a page with (customizable) lots of revisions
TypeSnippet
CategoryOther
Developed by

Ilie Andriuta

Rating
2 Votes
LicenseGNU Lesser General Public License 2.1

Table of contents

Description

The page name and the number of revisions can be customized.

{{groovy}}
// CONFIGURATION
def docName = "Sandbox.RevisionTest"  // Page to modify
def numRevisions = 100                // How many revisions to create

// ======================================================================

def doc = xwiki.getDocument(docName)
if (!doc) {
    println "Creating new document: ${docName}"
    doc = xwiki.createDocument("Sandbox", "RevisionTest")
    doc.content = "Initial content"
    doc.save("Initial save")
}

println "Starting to create ${numRevisions} revisions for ${docName}..."

(1..numRevisions).each { rev ->
    doc = xwiki.getDocument(docName) // Reload to ensure latest
    doc.content = """\
Auto-generated revision #${rev} at ${new Date()}

Random content: ${UUID.randomUUID().toString()}
"""
    doc.save("Automated revision ${rev}")
    if (rev % 10 == 0) {
        println "Created ${rev} revisions so far..."
    }
}

println "Done! Created ${numRevisions} revisions for ${docName}"
{{/groovy}}

Get Connected